@thymian/plugin-sampler 0.3.0-canary.20261007-e6cb8dc → 0.3.0-canary.20261007-cdbe1d3

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 (264) hide show
  1. package/dist/cli/check-result.d.ts +88 -0
  2. package/dist/cli/check-result.d.ts.map +1 -0
  3. package/dist/cli/check-result.js +160 -0
  4. package/dist/cli/check-result.js.map +1 -0
  5. package/dist/cli/commands/sampler/check.d.ts +32 -4
  6. package/dist/cli/commands/sampler/check.d.ts.map +1 -1
  7. package/dist/cli/commands/sampler/check.js +126 -88
  8. package/dist/cli/commands/sampler/check.js.map +1 -1
  9. package/dist/cli/commands/sampler/init.d.ts +4 -6
  10. package/dist/cli/commands/sampler/init.d.ts.map +1 -1
  11. package/dist/cli/commands/sampler/init.js +33 -49
  12. package/dist/cli/commands/sampler/init.js.map +1 -1
  13. package/dist/cli/commands/sampler/show.d.ts +11 -0
  14. package/dist/cli/commands/sampler/show.d.ts.map +1 -0
  15. package/dist/cli/commands/sampler/show.js +36 -0
  16. package/dist/cli/commands/sampler/show.js.map +1 -0
  17. package/dist/cli/commands/sampler/sync.d.ts +11 -0
  18. package/dist/cli/commands/sampler/sync.d.ts.map +1 -0
  19. package/dist/cli/commands/sampler/sync.js +65 -0
  20. package/dist/cli/commands/sampler/sync.js.map +1 -0
  21. package/dist/cli/commands/sampler/validate.d.ts +3 -10
  22. package/dist/cli/commands/sampler/validate.d.ts.map +1 -1
  23. package/dist/cli/commands/sampler/validate.js +57 -126
  24. package/dist/cli/commands/sampler/validate.js.map +1 -1
  25. package/dist/generation/closed-schema.d.ts +22 -0
  26. package/dist/generation/closed-schema.d.ts.map +1 -0
  27. package/dist/generation/closed-schema.js +45 -0
  28. package/dist/generation/closed-schema.js.map +1 -0
  29. package/dist/generation/content-type-strategies/json.content-type-strategy.d.ts.map +1 -1
  30. package/dist/generation/content-type-strategies/json.content-type-strategy.js +3 -1
  31. package/dist/generation/content-type-strategies/json.content-type-strategy.js.map +1 -1
  32. package/dist/generation/content-type-strategies/xml.content-type-strategy.d.ts.map +1 -1
  33. package/dist/generation/content-type-strategies/xml.content-type-strategy.js +3 -1
  34. package/dist/generation/content-type-strategies/xml.content-type-strategy.js.map +1 -1
  35. package/dist/generation/generate-request-sample.d.ts +12 -0
  36. package/dist/generation/generate-request-sample.d.ts.map +1 -0
  37. package/dist/generation/{generate-samples.js → generate-request-sample.js} +11 -4
  38. package/dist/generation/generate-request-sample.js.map +1 -0
  39. package/dist/generation/request-generators/default-request-generator.d.ts +14 -0
  40. package/dist/generation/request-generators/default-request-generator.d.ts.map +1 -1
  41. package/dist/generation/request-generators/default-request-generator.js +18 -1
  42. package/dist/generation/request-generators/default-request-generator.js.map +1 -1
  43. package/dist/generation/types/declaration-set.d.ts +124 -0
  44. package/dist/generation/types/declaration-set.d.ts.map +1 -0
  45. package/dist/generation/types/declaration-set.js +389 -0
  46. package/dist/generation/types/declaration-set.js.map +1 -0
  47. package/dist/generation/types/example-reflection.d.ts +21 -0
  48. package/dist/generation/types/example-reflection.d.ts.map +1 -0
  49. package/dist/generation/types/example-reflection.js +135 -0
  50. package/dist/generation/types/example-reflection.js.map +1 -0
  51. package/dist/generation/types/generate-type-surface.d.ts +23 -0
  52. package/dist/generation/types/generate-type-surface.d.ts.map +1 -0
  53. package/dist/generation/types/generate-type-surface.js +671 -0
  54. package/dist/generation/types/generate-type-surface.js.map +1 -0
  55. package/dist/generation/types/schema-type.d.ts +20 -0
  56. package/dist/generation/types/schema-type.d.ts.map +1 -0
  57. package/dist/generation/types/schema-type.js +203 -0
  58. package/dist/generation/types/schema-type.js.map +1 -0
  59. package/dist/generation/types/self-check-surface.d.ts +32 -0
  60. package/dist/generation/types/self-check-surface.d.ts.map +1 -0
  61. package/dist/generation/types/self-check-surface.js +92 -0
  62. package/dist/generation/types/self-check-surface.js.map +1 -0
  63. package/dist/generation/types/type-names.d.ts +135 -0
  64. package/dist/generation/types/type-names.d.ts.map +1 -0
  65. package/dist/generation/types/type-names.js +213 -0
  66. package/dist/generation/types/type-names.js.map +1 -0
  67. package/dist/generation/types/write-type-surface.d.ts +58 -0
  68. package/dist/generation/types/write-type-surface.d.ts.map +1 -0
  69. package/dist/generation/types/write-type-surface.js +119 -0
  70. package/dist/generation/types/write-type-surface.js.map +1 -0
  71. package/dist/hooks/create-hook-utils.d.ts +22 -6
  72. package/dist/hooks/create-hook-utils.d.ts.map +1 -1
  73. package/dist/hooks/create-hook-utils.js +74 -96
  74. package/dist/hooks/create-hook-utils.js.map +1 -1
  75. package/dist/hooks/hook-api.d.ts +49 -0
  76. package/dist/hooks/hook-api.d.ts.map +1 -0
  77. package/dist/hooks/hook-api.js +105 -0
  78. package/dist/hooks/hook-api.js.map +1 -0
  79. package/dist/hooks/hook-diagnostics.d.ts +45 -0
  80. package/dist/hooks/hook-diagnostics.d.ts.map +1 -0
  81. package/dist/hooks/hook-diagnostics.js +80 -0
  82. package/dist/hooks/hook-diagnostics.js.map +1 -0
  83. package/dist/hooks/hook-errors.d.ts +33 -0
  84. package/dist/hooks/hook-errors.d.ts.map +1 -1
  85. package/dist/hooks/hook-errors.js +46 -0
  86. package/dist/hooks/hook-errors.js.map +1 -1
  87. package/dist/hooks/hook-registration.d.ts +108 -0
  88. package/dist/hooks/hook-registration.d.ts.map +1 -0
  89. package/dist/hooks/hook-registration.js +69 -0
  90. package/dist/hooks/hook-registration.js.map +1 -0
  91. package/dist/hooks/hook-runner.d.ts +111 -11
  92. package/dist/hooks/hook-runner.d.ts.map +1 -1
  93. package/dist/hooks/hook-runner.js +309 -142
  94. package/dist/hooks/hook-runner.js.map +1 -1
  95. package/dist/hooks/hook-utils-factory.d.ts +19 -0
  96. package/dist/hooks/hook-utils-factory.d.ts.map +1 -0
  97. package/dist/hooks/hook-utils-factory.js +2 -0
  98. package/dist/hooks/hook-utils-factory.js.map +1 -0
  99. package/dist/hooks/hook-utils.d.ts +80 -12
  100. package/dist/hooks/hook-utils.d.ts.map +1 -1
  101. package/dist/hooks/invoke-hook.d.ts +71 -0
  102. package/dist/hooks/invoke-hook.d.ts.map +1 -0
  103. package/dist/hooks/invoke-hook.js +161 -0
  104. package/dist/hooks/invoke-hook.js.map +1 -0
  105. package/dist/hooks/load-user-hooks.d.ts +96 -0
  106. package/dist/hooks/load-user-hooks.d.ts.map +1 -0
  107. package/dist/hooks/load-user-hooks.js +432 -0
  108. package/dist/hooks/load-user-hooks.js.map +1 -0
  109. package/dist/hooks/nested-request.d.ts +21 -0
  110. package/dist/hooks/nested-request.d.ts.map +1 -0
  111. package/dist/hooks/nested-request.js +24 -0
  112. package/dist/hooks/nested-request.js.map +1 -0
  113. package/dist/hooks/overlay-args.d.ts +40 -0
  114. package/dist/hooks/overlay-args.d.ts.map +1 -0
  115. package/dist/hooks/overlay-args.js +84 -0
  116. package/dist/hooks/overlay-args.js.map +1 -0
  117. package/dist/hooks/resolve-targeting.d.ts +16 -0
  118. package/dist/hooks/resolve-targeting.d.ts.map +1 -0
  119. package/dist/hooks/resolve-targeting.js +168 -0
  120. package/dist/hooks/resolve-targeting.js.map +1 -0
  121. package/dist/hooks/run-scoped-hooks.d.ts +83 -0
  122. package/dist/hooks/run-scoped-hooks.d.ts.map +1 -0
  123. package/dist/hooks/run-scoped-hooks.js +153 -0
  124. package/dist/hooks/run-scoped-hooks.js.map +1 -0
  125. package/dist/index.d.ts +42 -19
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +152 -165
  128. package/dist/index.js.map +1 -1
  129. package/dist/request-sampler.d.ts +40 -11
  130. package/dist/request-sampler.d.ts.map +1 -1
  131. package/dist/request-sampler.js +51 -76
  132. package/dist/request-sampler.js.map +1 -1
  133. package/dist/sampler-paths.d.ts +19 -0
  134. package/dist/sampler-paths.d.ts.map +1 -0
  135. package/dist/sampler-paths.js +22 -0
  136. package/dist/sampler-paths.js.map +1 -0
  137. package/dist/selectors/nearest-paths.d.ts +14 -0
  138. package/dist/selectors/nearest-paths.d.ts.map +1 -0
  139. package/dist/selectors/nearest-paths.js +32 -0
  140. package/dist/selectors/nearest-paths.js.map +1 -0
  141. package/dist/selectors/path-glob.d.ts +94 -0
  142. package/dist/selectors/path-glob.d.ts.map +1 -0
  143. package/dist/selectors/path-glob.js +136 -0
  144. package/dist/selectors/path-glob.js.map +1 -0
  145. package/dist/selectors/selector-errors.d.ts +17 -0
  146. package/dist/selectors/selector-errors.d.ts.map +1 -0
  147. package/dist/selectors/selector-errors.js +139 -0
  148. package/dist/selectors/selector-errors.js.map +1 -0
  149. package/dist/selectors/selector.d.ts +55 -0
  150. package/dist/selectors/selector.d.ts.map +1 -0
  151. package/dist/selectors/selector.js +305 -0
  152. package/dist/selectors/selector.js.map +1 -0
  153. package/dist/selectors/transaction-catalog.d.ts +96 -0
  154. package/dist/selectors/transaction-catalog.d.ts.map +1 -0
  155. package/dist/selectors/transaction-catalog.js +193 -0
  156. package/dist/selectors/transaction-catalog.js.map +1 -0
  157. package/dist/selectors/transaction-filter.d.ts +119 -0
  158. package/dist/selectors/transaction-filter.d.ts.map +1 -0
  159. package/dist/selectors/transaction-filter.js +191 -0
  160. package/dist/selectors/transaction-filter.js.map +1 -0
  161. package/dist/ts-path.d.ts +36 -0
  162. package/dist/ts-path.d.ts.map +1 -0
  163. package/dist/ts-path.js +46 -0
  164. package/dist/ts-path.js.map +1 -0
  165. package/dist/utils.d.ts +1 -2
  166. package/dist/utils.d.ts.map +1 -1
  167. package/dist/utils.js +2 -20
  168. package/dist/utils.js.map +1 -1
  169. package/dist/validation/canonicalize.d.ts +17 -0
  170. package/dist/validation/canonicalize.d.ts.map +1 -0
  171. package/dist/validation/canonicalize.js +29 -0
  172. package/dist/validation/canonicalize.js.map +1 -0
  173. package/dist/validation/shared-compiler-host.d.ts +17 -0
  174. package/dist/validation/shared-compiler-host.d.ts.map +1 -0
  175. package/dist/validation/shared-compiler-host.js +58 -0
  176. package/dist/validation/shared-compiler-host.js.map +1 -0
  177. package/dist/validation/typecheck-hooks.d.ts +37 -0
  178. package/dist/validation/typecheck-hooks.d.ts.map +1 -0
  179. package/dist/validation/typecheck-hooks.js +169 -0
  180. package/dist/validation/typecheck-hooks.js.map +1 -0
  181. package/dist/validation/validate-sampler.d.ts +79 -0
  182. package/dist/validation/validate-sampler.d.ts.map +1 -0
  183. package/dist/validation/validate-sampler.js +89 -0
  184. package/dist/validation/validate-sampler.js.map +1 -0
  185. package/package.json +7 -11
  186. package/dist/cli/commands/sampler/generate/hook.d.ts +0 -10
  187. package/dist/cli/commands/sampler/generate/hook.d.ts.map +0 -1
  188. package/dist/cli/commands/sampler/generate/hook.js +0 -19
  189. package/dist/cli/commands/sampler/generate/hook.js.map +0 -1
  190. package/dist/cli/generate-hook.d.ts +0 -4
  191. package/dist/cli/generate-hook.d.ts.map +0 -1
  192. package/dist/cli/generate-hook.js +0 -96
  193. package/dist/cli/generate-hook.js.map +0 -1
  194. package/dist/cli/templates.d.ts +0 -4
  195. package/dist/cli/templates.d.ts.map +0 -1
  196. package/dist/cli/templates.js +0 -28
  197. package/dist/cli/templates.js.map +0 -1
  198. package/dist/constants.d.ts +0 -12
  199. package/dist/constants.d.ts.map +0 -1
  200. package/dist/constants.js +0 -16
  201. package/dist/constants.js.map +0 -1
  202. package/dist/generation/generate-samples-for-thymian-format.d.ts +0 -4
  203. package/dist/generation/generate-samples-for-thymian-format.d.ts.map +0 -1
  204. package/dist/generation/generate-samples-for-thymian-format.js +0 -18
  205. package/dist/generation/generate-samples-for-thymian-format.js.map +0 -1
  206. package/dist/generation/generate-samples.d.ts +0 -4
  207. package/dist/generation/generate-samples.d.ts.map +0 -1
  208. package/dist/generation/generate-samples.js.map +0 -1
  209. package/dist/hooks/generate-request-types.d.ts +0 -34
  210. package/dist/hooks/generate-request-types.d.ts.map +0 -1
  211. package/dist/hooks/generate-request-types.js +0 -458
  212. package/dist/hooks/generate-request-types.js.map +0 -1
  213. package/dist/hooks/hook-types.d.ts +0 -7
  214. package/dist/hooks/hook-types.d.ts.map +0 -1
  215. package/dist/hooks/hook-types.js +0 -2
  216. package/dist/hooks/hook-types.js.map +0 -1
  217. package/dist/hooks/load-hooks-from-samples.d.ts +0 -3
  218. package/dist/hooks/load-hooks-from-samples.d.ts.map +0 -1
  219. package/dist/hooks/load-hooks-from-samples.js +0 -22
  220. package/dist/hooks/load-hooks-from-samples.js.map +0 -1
  221. package/dist/hooks/ts-config.d.ts +0 -10
  222. package/dist/hooks/ts-config.d.ts.map +0 -1
  223. package/dist/hooks/ts-config.js +0 -10
  224. package/dist/hooks/ts-config.js.map +0 -1
  225. package/dist/samples-structure/file-request-sample.d.ts +0 -20
  226. package/dist/samples-structure/file-request-sample.d.ts.map +0 -1
  227. package/dist/samples-structure/file-request-sample.js +0 -5
  228. package/dist/samples-structure/file-request-sample.js.map +0 -1
  229. package/dist/samples-structure/get-path-transaction-id.d.ts +0 -3
  230. package/dist/samples-structure/get-path-transaction-id.d.ts.map +0 -1
  231. package/dist/samples-structure/get-path-transaction-id.js +0 -22
  232. package/dist/samples-structure/get-path-transaction-id.js.map +0 -1
  233. package/dist/samples-structure/merge-tree.d.ts +0 -5
  234. package/dist/samples-structure/merge-tree.d.ts.map +0 -1
  235. package/dist/samples-structure/merge-tree.js +0 -118
  236. package/dist/samples-structure/merge-tree.js.map +0 -1
  237. package/dist/samples-structure/read-samples-from-dir.d.ts +0 -13
  238. package/dist/samples-structure/read-samples-from-dir.d.ts.map +0 -1
  239. package/dist/samples-structure/read-samples-from-dir.js +0 -205
  240. package/dist/samples-structure/read-samples-from-dir.js.map +0 -1
  241. package/dist/samples-structure/samples-from-transactions.d.ts +0 -5
  242. package/dist/samples-structure/samples-from-transactions.d.ts.map +0 -1
  243. package/dist/samples-structure/samples-from-transactions.js +0 -120
  244. package/dist/samples-structure/samples-from-transactions.js.map +0 -1
  245. package/dist/samples-structure/samples-tree-structure.d.ts +0 -106
  246. package/dist/samples-structure/samples-tree-structure.d.ts.map +0 -1
  247. package/dist/samples-structure/samples-tree-structure.js +0 -26
  248. package/dist/samples-structure/samples-tree-structure.js.map +0 -1
  249. package/dist/samples-structure/structure-meta-on-disc.d.ts +0 -11
  250. package/dist/samples-structure/structure-meta-on-disc.d.ts.map +0 -1
  251. package/dist/samples-structure/structure-meta-on-disc.js +0 -2
  252. package/dist/samples-structure/structure-meta-on-disc.js.map +0 -1
  253. package/dist/samples-structure/traverse.d.ts +0 -4
  254. package/dist/samples-structure/traverse.d.ts.map +0 -1
  255. package/dist/samples-structure/traverse.js +0 -13
  256. package/dist/samples-structure/traverse.js.map +0 -1
  257. package/dist/samples-structure/write-samples-to-dir.d.ts +0 -37
  258. package/dist/samples-structure/write-samples-to-dir.d.ts.map +0 -1
  259. package/dist/samples-structure/write-samples-to-dir.js +0 -183
  260. package/dist/samples-structure/write-samples-to-dir.js.map +0 -1
  261. package/dist/validation/validate-sampler-output.d.ts +0 -38
  262. package/dist/validation/validate-sampler-output.d.ts.map +0 -1
  263. package/dist/validation/validate-sampler-output.js +0 -288
  264. package/dist/validation/validate-sampler-output.js.map +0 -1
@@ -1,59 +1,43 @@
1
- import { BaseCliRunCommand, oclif, prompts } from '@thymian/common-cli';
1
+ import { join, relative } from 'node:path';
2
+ import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
3
+ const { colorize } = oclif.ux;
2
4
  export default class Init extends BaseCliRunCommand {
3
- static description = 'Generate initial sampler files for the current API specification.';
4
- static flags = {
5
- overwrite: oclif.Flags.boolean({
6
- default: false,
7
- description: 'Overwrite existing samples.',
8
- }),
9
- check: oclif.Flags.boolean({
10
- description: 'After initialization, run sampler check to verify all transactions can be executed.',
11
- allowNo: true,
12
- default: false,
13
- }),
14
- };
5
+ static enableJsonFlag = true;
6
+ static description = 'Set up the sampler for editor support: generate the committed type surface and scaffold a tsconfig.';
7
+ static examples = ['<%= config.bin %> <%= command.id %>'];
15
8
  async run() {
16
- await this.thymian.run(async (emitter) => {
17
- if (!this.thymian.plugins.find((p) => p.plugin.name === '@thymian/plugin-sampler')) {
18
- this.error('Cannot initialize sampler if sampler plugin is not registered.', {
19
- exit: 1,
20
- });
21
- }
22
- const format = await this.thymian.loadFormat({
9
+ return this.thymian.run(async (emitter) => {
10
+ await this.thymian.loadFormat({
23
11
  inputs: this.thymianConfig.specifications ?? [],
24
12
  validateSpecs: this.flags['validate-specs'],
25
- }, {
26
- emitFormat: true,
27
- });
28
- await emitter.emitAction('sampler.init', {
29
- format: format.export(),
30
- overwrite: this.flags.overwrite,
31
- });
32
- });
33
- this.log(oclif.ux.colorize('green', 'Sampler initialized.'));
34
- if (this.flags.check) {
35
- if (this.config.findCommand('sampler check')) {
13
+ },
14
+ // The sampler builds its catalog on `core.format`, and the type surface
15
+ // is generated from that catalog.
16
+ { emitFormat: true });
17
+ const result = await emitter.emitAction('sampler.init', {}, { strategy: 'first' });
18
+ if (this.jsonEnabled()) {
19
+ return result;
20
+ }
21
+ const root = relative(this.flags.cwd, result.root) || result.root;
22
+ // `result.generated` names files inside the surface directory, so the
23
+ // segment has to be put back: without it the command reports a path that
24
+ // does not exist.
25
+ for (const file of result.generated) {
26
+ this.log(`${colorize('green', 'created')} ${join(root, 'generated', file)}`);
27
+ }
28
+ if (result.tsconfig === 'written') {
29
+ this.log(`${colorize('green', 'created')} ${join(root, 'tsconfig.json')}`);
30
+ }
31
+ if (result.rootExcludeNote.length > 0) {
32
+ this.log();
33
+ this.log('One thing left, which only you can do:');
36
34
  this.log();
37
- const answer = await prompts.confirm({
38
- message: 'Do you want to run this check now?',
39
- });
40
- if (answer) {
41
- this.log();
42
- const args = ['--cwd', this.flags.cwd];
43
- if (this.flags.config) {
44
- args.push('-c', this.flags.config);
45
- }
46
- await this.config.runCommand('sampler check', args);
35
+ for (const line of result.rootExcludeNote) {
36
+ this.log(` ${line}`);
47
37
  }
48
38
  }
49
- }
50
- else {
51
- this.log();
52
- this.log('To check if every transaction can be executed, run:');
53
- this.log();
54
- this.log('$ thymian sampler check');
55
- this.log();
56
- }
39
+ return result;
40
+ });
57
41
  }
58
42
  }
59
43
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAA8B;IAC9D,MAAM,CAAU,WAAW,GACzB,mEAAmE,CAAC;IAEtE,MAAM,CAAU,KAAK,GAAG;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YAC7B,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,6BAA6B;SAC3C,CAAC;QAEF,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YACzB,WAAW,EACT,qFAAqF;YACvF,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;SACf,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvC,IACE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CACxB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,yBAAyB,CACnD,EACD,CAAC;gBACD,IAAI,CAAC,KAAK,CACR,gEAAgE,EAChE;oBACE,IAAI,EAAE,CAAC;iBACR,CACF,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAC1C;gBACE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,IAAI,EAAE;gBAC/C,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC;aAC5C,EACD;gBACE,UAAU,EAAE,IAAI;aACjB,CACF,CAAC;YAEF,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE;gB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Q,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,CACnE,CAAC;YACJ,CAAC;YAED,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAClC,IAAI,CAAC,GAAG,CACN,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,CACjE,CAAC;YACJ,CAAC;YAED,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACX,IAAI,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;gBACnD,IAAI,CAAC,GAAG,EAAE,CAAC;gBAEX,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;oBAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
+ export default class Show extends BaseCliRunCommand<typeof Show> {
3
+ static enableJsonFlag: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static args: {
7
+ selector: oclif.Interfaces.Arg<string, Record<string, unknown>>;
8
+ };
9
+ run(): Promise<unknown>;
10
+ }
11
+ //# sourceMappingURL=show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG/D,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAAiB,CAAC,OAAO,IAAI,CAAC;IAC9D,OAAgB,cAAc,UAAQ;IAEtC,OAAgB,WAAW,SAC2C;IAEtE,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,IAAI;;MAMlB;IAEa,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CA6BvC"}
@@ -0,0 +1,36 @@
1
+ import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
+ import { Args } from '@thymian/common-cli/oclif';
3
+ export default class Show extends BaseCliRunCommand {
4
+ static enableJsonFlag = true;
5
+ static description = 'Print the freshly generated request for one transaction selector.';
6
+ static examples = [
7
+ '<%= config.bin %> <%= command.id %> "GET /launches -> 200 (application/json)"',
8
+ '<%= config.bin %> <%= command.id %> "DELETE /astronauts/{id} -> 204" --json',
9
+ ];
10
+ static args = {
11
+ selector: Args.string({
12
+ required: true,
13
+ description: 'The transaction selector, as METHOD path [(requestMediaType)] -> status [(responseMediaType)].',
14
+ }),
15
+ };
16
+ async run() {
17
+ return this.thymian.run(async (emitter) => {
18
+ await this.thymian.loadFormat({
19
+ inputs: this.thymianConfig.specifications ?? [],
20
+ validateSpecs: this.flags['validate-specs'],
21
+ },
22
+ // The sampler answers from the projection it builds on `core.format`,
23
+ // so the format has to reach it before the selector is resolved.
24
+ { emitFormat: true });
25
+ const shown = await emitter.emitAction('sampler.show', { selector: this.args.selector }, { strategy: 'first' });
26
+ if (this.jsonEnabled()) {
27
+ return shown;
28
+ }
29
+ this.log(oclif.ux.colorize('bold', shown.selector));
30
+ this.log();
31
+ this.log(JSON.stringify(shown.request, null, 2));
32
+ return shown;
33
+ });
34
+ }
35
+ }
36
+ //# sourceMappingURL=show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO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QACf,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
+ export default class Sync extends BaseCliRunCommand<typeof Sync> {
3
+ static enableJsonFlag: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ check: oclif.Interfaces.BooleanFlag<boolean>;
8
+ };
9
+ run(): Promise<unknown>;
10
+ }
11
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG/D,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAAiB,CAAC,OAAO,IAAI,CAAC;IAC9D,OAAgB,cAAc,UAAQ;IAEtC,OAAgB,WAAW,SACkD;IAE7E,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;MAMnB;IAEa,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CA6EvC"}
@@ -0,0 +1,65 @@
1
+ import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
+ import { Flags } from '@thymian/common-cli/oclif';
3
+ export default class Sync extends BaseCliRunCommand {
4
+ static enableJsonFlag = true;
5
+ static description = 'Regenerate the committed sampler types from the current API description.';
6
+ static examples = [
7
+ '<%= config.bin %> <%= command.id %>',
8
+ '<%= config.bin %> <%= command.id %> --check',
9
+ ];
10
+ static flags = {
11
+ check: Flags.boolean({
12
+ default: false,
13
+ description: 'Report whether regeneration would change the committed types, and write nothing. Exits non-zero if it would.',
14
+ }),
15
+ };
16
+ async run() {
17
+ return this.thymian.run(async (emitter) => {
18
+ await this.thymian.loadFormat({
19
+ inputs: this.thymianConfig.specifications ?? [],
20
+ validateSpecs: this.flags['validate-specs'],
21
+ }, { emitFormat: true });
22
+ const result = await emitter.emitAction('sampler.sync', { check: this.flags.check }, { strategy: 'first' });
23
+ if (this.jsonEnabled()) {
24
+ if (this.flags.check && result.changed.length > 0) {
25
+ process.exitCode = 1;
26
+ }
27
+ return result;
28
+ }
29
+ if (result.changed.length === 0) {
30
+ this.log('Sampler types are in sync.');
31
+ // The types matched but the bytes moved — a description edit rewrites a
32
+ // JSDoc comment without moving a type. Saying so is the difference
33
+ // between an explained diff and a mysterious one.
34
+ if (result.rewritten && result.rewritten.length > 0) {
35
+ this.log();
36
+ this.log(oclif.ux.colorize('dim', 'Rewritten anyway, with no change to any type — commit or discard as you like:'));
37
+ for (const file of result.rewritten) {
38
+ this.log(oclif.ux.colorize('dim', ` generated/${file}`));
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+ if (this.flags.check) {
44
+ this.log(oclif.ux.colorize('red', `Sampler types are out of sync:`));
45
+ for (const file of result.changed) {
46
+ this.log(` ${file}`);
47
+ this.log();
48
+ }
49
+ this.guidance('To regenerate the types, run:\n $ thymian sampler sync');
50
+ // `process.exitCode` rather than `this.exit()`: an early exit throws
51
+ // past this run's teardown, and routes through oclif's error path —
52
+ // a feedback prompt and an error-cache record for what is a legitimate
53
+ // gate verdict, not a crash (mirrors `sampler check`'s outcome model).
54
+ process.exitCode = 1;
55
+ return result;
56
+ }
57
+ this.log(oclif.ux.colorize('green', 'Regenerated:'));
58
+ for (const file of result.changed) {
59
+ this.log(` ${file}`);
60
+ }
61
+ return result;
62
+ });
63
+ }
64
+ }
65
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAA8B;IAC9D,MAAM,CAAU,cAAc,GAAG,I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,CAAC"}
@@ -1,15 +1,8 @@
1
- import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
- import type { SamplerValidationReport } from '../../../validation/validate-sampler-output.js';
1
+ import { BaseCliRunCommand } from '@thymian/common-cli';
3
2
  export default class Validate extends BaseCliRunCommand<typeof Validate> {
4
3
  static enableJsonFlag: boolean;
5
4
  static description: string;
6
- static flags: {
7
- "full-diffs": oclif.Interfaces.BooleanFlag<boolean>;
8
- "for-path": oclif.Interfaces.OptionFlag<string | undefined, oclif.Interfaces.CustomOptions>;
9
- };
10
- run(): Promise<SamplerValidationReport>;
11
- private logFailure;
12
- private logJsonChanges;
13
- private logContentField;
5
+ static examples: string[];
6
+ run(): Promise<unknown>;
14
7
  }
15
8
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAQ/D,OAAO,KAAK,EAIV,uBAAuB,EACxB,MAAM,gDAAgD,CAAC;AAiBxD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,iBAAiB,CAAC,OAAO,QAAQ,CAAC;IACtE,OAAgB,cAAc,UAAQ;IAEtC,OAAgB,WAAW,SACiD;IAE5E,OAAgB,KAAK;;;MAUnB;IAEI,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAoH7C,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,eAAe;CAcxB"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAS,MAAM,qBAAqB,CAAC;AAE/D,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,iBAAiB,CAAC,OAAO,QAAQ,CAAC;IACtE,OAAgB,cAAc,UAAQ;IAEtC,OAAgB,WAAW,SAC4E;IAEvG,OAAgB,QAAQ,WAA2C;IAEpD,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CAuHvC"}
@@ -1,147 +1,78 @@
1
1
  import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
- import { SEVERITY_COLORS, SEVERITY_SYMBOLS, successSymbol, } from '@thymian/core';
3
- const { colorize } = oclif.ux;
4
- // Map each finding to a core report severity so the command reuses the exact
5
- // colors and symbols of the Thymian report renderer (see report-style.ts)
6
- // without constructing a Report. A missing/changed artifact is an error; an
7
- // unexpected extra file is a warning.
8
- const FINDING_SEVERITY = {
9
- 'missing-artifact': 'error',
10
- 'changed-artifact': 'error',
11
- 'stale-root-metadata': 'error',
12
- 'metadata-out-of-sync': 'error',
13
- 'invalid-json': 'error',
14
- 'unexpected-artifact': 'warn',
15
- };
16
2
  export default class Validate extends BaseCliRunCommand {
17
3
  static enableJsonFlag = true;
18
- static description = 'Validate generated sampler artifacts for the current API specification.';
19
- static flags = {
20
- ['full-diffs']: oclif.Flags.boolean({
21
- default: false,
22
- description: 'Show the full diff for every out-of-sync artifact instead of a summary.',
23
- }),
24
- ['for-path']: oclif.Flags.string({
25
- description: 'Validate a single generated artifact by its relative path (e.g. meta.json) and show its full diff. Note: the full artifact set is still regenerated internally, so this scopes the output, not the work.',
26
- }),
27
- };
4
+ static description = 'Check the sampler hooks against the current API description, and the committed types against both.';
5
+ static examples = ['<%= config.bin %> <%= command.id %>'];
28
6
  async run() {
29
7
  return this.thymian.run(async (emitter) => {
30
- if (!this.thymian.plugins.find((p) => p.plugin.name === '@thymian/plugin-sampler')) {
31
- this.error('Cannot validate sampler if sampler plugin is not registered.', {
32
- exit: 1,
33
- });
34
- }
35
- const format = await this.thymian.loadFormat({
8
+ await this.thymian.loadFormat({
36
9
  inputs: this.thymianConfig.specifications ?? [],
37
10
  validateSpecs: this.flags['validate-specs'],
38
- }, {
39
- emitFormat: false,
40
- });
41
- const forPath = this.flags['for-path'];
42
- const report = await emitter.emitAction('sampler.validate', {
43
- format: format.export(),
44
- ...(forPath !== undefined ? { forPath } : {}),
45
- }, {
46
- strategy: 'first',
47
- });
48
- // A scoped run reports 0 checked artifacts only when the path is not a
49
- // known generated artifact — surface that as an error in every mode.
50
- if (forPath !== undefined && report.checkedArtifacts === 0) {
51
- if (this.jsonEnabled()) {
52
- // Keep machine output consistent: emit the (empty) report as JSON and
53
- // signal the usage error through the exit code instead of throwing,
54
- // which would abort before any JSON is printed.
55
- process.exitCode = 2;
56
- return report;
57
- }
58
- this.error(`No generated sampler artifact found at path "${forPath}".`, {
59
- exit: 2,
60
- });
61
- }
11
+ }, { emitFormat: true });
12
+ const report = await emitter.emitAction('sampler.validate', {}, { strategy: 'first' });
62
13
  if (this.jsonEnabled()) {
63
- // oclif serializes the returned value as JSON and suppresses `this.log`.
64
- // Signal failure through the exit code without throwing, because a throw
65
- // would abort before the JSON is printed.
66
- if (report.failures.length > 0) {
14
+ if (report.verdict === 'broken' || report.verdict === 'drifted') {
67
15
  process.exitCode = 1;
68
16
  }
69
17
  return report;
70
18
  }
71
- if (report.failures.length === 0) {
72
- this.log(`${colorize(SEVERITY_COLORS.info, successSymbol)} ${forPath !== undefined
73
- ? `Generated sampler artifact "${forPath}" is in sync.`
74
- : `Sampler validation passed: ${report.checkedArtifacts} generated artifacts are in sync.`}`);
75
- return report;
76
- }
77
- // `--for-path` targets one artifact, so its diff is always shown;
78
- // otherwise details are opt-in via `--full-diffs`.
79
- const showDiffs = this.flags['full-diffs'] || forPath !== undefined;
80
- for (const failure of report.failures) {
81
- this.logFailure(failure, showDiffs);
19
+ for (const warning of report.warnings) {
20
+ this.log(oclif.ux.colorize('yellow', `! ${warning}`));
82
21
  }
83
- const checked = report.checkedArtifacts;
84
- // `checkedArtifacts` counts only expected (generated) artifacts, so keep
85
- // unexpected extras in their own tally — otherwise "N failed" against
86
- // "Checked M" reads as "N of M generated artifacts failed" when the extras
87
- // were never part of that set.
88
- const unexpected = report.failures.filter((failure) => failure.type === 'unexpected-artifact').length;
89
- const outOfSync = report.failures.length - unexpected;
90
- const summaryParts = [];
91
- if (outOfSync > 0) {
92
- summaryParts.push(`${outOfSync} out of sync`);
22
+ for (const problem of [
23
+ ...report.unresolved,
24
+ ...report.conflicts,
25
+ ...report.unexported,
26
+ ]) {
27
+ const where = problem.exportName
28
+ ? `${problem.file} (export "${problem.exportName}")`
29
+ : problem.file;
30
+ this.log(oclif.ux.colorize('red', `✖ ${where}: ${problem.reason}`));
31
+ for (const suggestion of problem.suggestions ?? []) {
32
+ this.log(oclif.ux.colorize('dim', ` ${suggestion}`));
33
+ }
93
34
  }
94
- if (unexpected > 0) {
95
- summaryParts.push(`${unexpected} unexpected`);
35
+ for (const error of report.typeErrors) {
36
+ this.log(oclif.ux.colorize('red', `✖ ${error.file}:${error.line}:${error.column} — TS${error.code}: ${error.message}`));
96
37
  }
97
- this.log();
98
- this.log(`Checked ${checked} generated ${checked === 1 ? 'artifact' : 'artifacts'} in ${report.samplePath}. ${colorize(SEVERITY_COLORS.error, `${summaryParts.join(', ')}.`)}`);
99
- this.exit(1);
100
- });
101
- }
102
- logFailure(failure, showDiffs) {
103
- const severity = FINDING_SEVERITY[failure.type];
104
- const color = SEVERITY_COLORS[severity];
105
- const symbol = SEVERITY_SYMBOLS[severity];
106
- this.log(`${colorize(color, `${symbol} ${failure.type}`)}: ${failure.path}`);
107
- if (!showDiffs) {
108
- return;
109
- }
110
- this.log(colorize(SEVERITY_COLORS.info, ` ${failure.message}`));
111
- if (failure.changes && failure.changes.length > 0) {
112
- this.logJsonChanges(failure.changes);
113
- }
114
- else {
115
- this.logContentField('expected', failure.expected);
116
- this.logContentField('actual', failure.actual);
117
- }
118
- this.log();
119
- }
120
- logJsonChanges(changes) {
121
- this.log(colorize(SEVERITY_COLORS.info, ' JSON changes:'));
122
- for (const change of changes) {
123
- const pointer = change.pointer || '/';
124
- let detail;
125
- if (change.type === 'add') {
126
- detail = `[add] ${pointer} → ${JSON.stringify(change.actual)}`;
38
+ // `process.exitCode` rather than `this.exit()` for both verdicts below:
39
+ // an early exit throws past this run's teardown and routes through
40
+ // oclif's error path — a feedback prompt and an error-cache record for
41
+ // what is a legitimate gate verdict, not a crash (mirrors `sampler
42
+ // check`'s outcome model).
43
+ if (report.verdict === 'drifted') {
44
+ this.log();
45
+ this.log('Breaking drift: the API description no longer matches these hooks.');
46
+ this.log('Fix them, run "thymian sampler sync", and commit the result.');
47
+ process.exitCode = 1;
48
+ return report;
127
49
  }
128
- else if (change.type === 'delete') {
129
- detail = `[delete] ${pointer} (was ${JSON.stringify(change.expected)})`;
50
+ if (report.verdict === 'broken') {
51
+ this.log();
52
+ this.log('These hooks do not compile against the current API description.');
53
+ // Deliberately not "run sync": the committed types already match the
54
+ // description, so regenerating would rewrite correct files and leave
55
+ // the real error exactly where it is.
56
+ this.log(report.surface === 'absent'
57
+ ? 'Fix them. Nothing is committed, so there is nothing to regenerate.'
58
+ : 'Fix them. The committed types are already in sync — there is no drift to resolve.');
59
+ process.exitCode = 1;
60
+ return report;
130
61
  }
131
- else {
132
- detail = `[update] ${pointer}: ${JSON.stringify(change.expected)} → ${JSON.stringify(change.actual)}`;
62
+ if (report.verdict === 'stale') {
63
+ this.log(oclif.ux.colorize('yellow', '! The committed sampler types are behind this API description, but every hook still compiles:'));
64
+ for (const file of report.changedFiles) {
65
+ this.log(oclif.ux.colorize('dim', ` generated/${file}`));
66
+ }
67
+ this.log();
68
+ this.log('Run "thymian sampler sync" and commit the result.');
69
+ return report;
133
70
  }
134
- this.log(colorize(SEVERITY_COLORS.info, ` ${detail}`));
135
- }
136
- }
137
- logContentField(label, value) {
138
- if (value === undefined) {
139
- return;
140
- }
141
- this.log(colorize(SEVERITY_COLORS.info, ` ${label}:`));
142
- for (const line of value.split('\n')) {
143
- this.log(colorize(SEVERITY_COLORS.info, ` ${line}`));
144
- }
71
+ this.log(oclif.ux.colorize('green', report.surface === 'absent'
72
+ ? 'Every hook resolves. Run "thymian sampler init" for editor support and a type gate.'
73
+ : 'Every hook resolves and the committed types match this API description.'));
74
+ return report;
75
+ });
145
76
  }
146
77
  }
147
78
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAC;AASvB,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;AAE9B,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,sCAAsC;AACtC,MAAM,gBAAgB,GAAmD;IACvE,kBAAkB,EAAE,OAAO;IAC3B,kBAAkB,EAAE,OAAO;IAC3B,qBAAqB,EAAE,OAAO;IAC9B,sBAAsB,EAAE,OAAO;IAC/B,cAAc,EAAE,OAAO;IACvB,qBAAqB,EAAE,MAAM;CAC9B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,iBAAkC;IACtE,MAAM,CAAU,cAAc,GAAG,IAAI,CAAC;IAEtC,MAAM,CAAU,WAAW,GACzB,yEAAyE,CAAC;IAE5E,MAAM,CAAU,KAAK,GAAG;QACtB,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YAClC,OAAO,EAAE,KAAK;YACd,WAAW,EACT,yEAAyE;SAC5E,CAAC;QACF,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;YAC/B,WAAW,EACT,0MAA0M;SAC7M,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACxC,IACE,CAAC,IAAI,CAAC,OAAO,CAAC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AAC,GAAG,CACN,KAAK,CAAC,EAAE,CAAC,QAAQ,CACf,OAAO,EACP,MAAM,CAAC,OAAO,KAAK,QAAQ;gBACzB,CAAC,CAAC,qFAAqF;gBACvF,CAAC,CAAC,yEAAyE,CAC9E,CACF,CAAC;YAEF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Restores the boolean form of a schema that forbids everything.
3
+ *
4
+ * `additionalProperties: false` reaches the sampler as `{ not: {} }`, which is
5
+ * the correct JSON Schema for it (`plugin-openapi`'s `normalizeSchema` turns
6
+ * every boolean schema into its object form). Two consumers misread it, since
7
+ * both treat any object in that position as a value schema:
8
+ *
9
+ * - the type emitter emits `[k: string]: { [k: string]: unknown }`, an index
10
+ * signature that every declared property then fails to satisfy — `TS2411`,
11
+ * six times over on the demo description;
12
+ * - `openapi-sampler` invents `property1`, `property2` for it, which the same
13
+ * schema forbids.
14
+ *
15
+ * Handed the boolean, the emitter emits no index signature and the sampler
16
+ * invents nothing, which is what a closed object is.
17
+ *
18
+ * Only this position is rewritten. `{ not: {} }` elsewhere means `never`, which
19
+ * the emitter is free to render however it likes.
20
+ */
21
+ export declare function closedObjectsToBoolean(input: unknown): unknown;
22
+ //# sourceMappingURL=closed-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closed-schema.d.ts","sourceRoot":"","sources":["../../src/generation/closed-schema.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmB9D"}
@@ -0,0 +1,45 @@
1
+ import { isRecord } from '@thymian/core';
2
+ /**
3
+ * Restores the boolean form of a schema that forbids everything.
4
+ *
5
+ * `additionalProperties: false` reaches the sampler as `{ not: {} }`, which is
6
+ * the correct JSON Schema for it (`plugin-openapi`'s `normalizeSchema` turns
7
+ * every boolean schema into its object form). Two consumers misread it, since
8
+ * both treat any object in that position as a value schema:
9
+ *
10
+ * - the type emitter emits `[k: string]: { [k: string]: unknown }`, an index
11
+ * signature that every declared property then fails to satisfy — `TS2411`,
12
+ * six times over on the demo description;
13
+ * - `openapi-sampler` invents `property1`, `property2` for it, which the same
14
+ * schema forbids.
15
+ *
16
+ * Handed the boolean, the emitter emits no index signature and the sampler
17
+ * invents nothing, which is what a closed object is.
18
+ *
19
+ * Only this position is rewritten. `{ not: {} }` elsewhere means `never`, which
20
+ * the emitter is free to render however it likes.
21
+ */
22
+ export function closedObjectsToBoolean(input) {
23
+ if (Array.isArray(input)) {
24
+ return input.map(closedObjectsToBoolean);
25
+ }
26
+ if (!isRecord(input)) {
27
+ return input;
28
+ }
29
+ const out = {};
30
+ for (const [key, value] of Object.entries(input)) {
31
+ out[key] =
32
+ key === 'additionalProperties' && forbidsEverything(value)
33
+ ? false
34
+ : closedObjectsToBoolean(value);
35
+ }
36
+ return out;
37
+ }
38
+ /** Whether a schema admits no value at all, in the shape normalization emits. */
39
+ function forbidsEverything(schema) {
40
+ return (isRecord(schema) &&
41
+ Object.keys(schema).length === 1 &&
42
+ isRecord(schema['not']) &&
43
+ Object.keys(schema['not']).length === 0);
44
+ }
45
+ //# sourceMappingURL=closed-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closed-schema.js","sourceRoot":"","sources":["../../src/generation/closed-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,GAAG,GAA4B,EAAE,CAAC;IAExC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,GAAG,CAAC;YACN,GAAG,KAAK,sBAAsB,IAAI,iBAAiB,CAAC,KAAK,CAAC;gBACxD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iFAAiF;AACjF,SAAS,iBAAiB,CAAC,MAAe;IACxC,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;QAChC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CACxC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"json.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/json.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAK9D"}
1
+ {"version":3,"file":"json.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/json.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAO9D"}