@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
@@ -0,0 +1,37 @@
1
+ import { type TypeSurface } from '../generation/types/generate-type-surface.js';
2
+ import type { SamplerPaths } from '../sampler-paths.js';
3
+ /** One `tsc` complaint about a hook, as a reader needs it. */
4
+ export type HookTypeError = {
5
+ /** Path of the hook file, relative to the sampler root. */
6
+ file: string;
7
+ /** 1-based line and column. */
8
+ line: number;
9
+ column: number;
10
+ /** `tsc`'s own message, flattened. */
11
+ message: string;
12
+ /** `tsc`'s error code, so a reader can look it up. */
13
+ code: number;
14
+ };
15
+ /**
16
+ * Type-check the user's hooks against a **freshly generated** surface.
17
+ *
18
+ * The fresh surface, not the committed one: the question `validate` answers is
19
+ * whether the hooks still fit the API description as it is now. Comparing
20
+ * against what is committed would only tell the user whether they had run
21
+ * `sync`, which is the other half of the gate.
22
+ *
23
+ * The surface is written to a temporary directory, so the check never
24
+ * disturbs what is committed — a `validate` that rewrote `generated/` would
25
+ * make `sync --check` pass by having run.
26
+ *
27
+ * The user's own tsconfig supplies the compiler options where it exists,
28
+ * because their hooks are written under those settings. `paths` is *merged*,
29
+ * not replaced: the `@thymian/hooks` alias is added as an **absolute**
30
+ * mapping (to the scratch surface), which TypeScript resolves ahead of
31
+ * `baseUrl` regardless of what the user set it to — see
32
+ * {@link mergeHooksAlias}. A hooks author with their own extra `paths`
33
+ * aliases gets the same resolution their editor gives them; replacing the
34
+ * whole map, as this once did, silently broke every alias the user added.
35
+ */
36
+ export declare function typecheckHooks(paths: SamplerPaths, surface: TypeSurface, hookFiles: readonly string[]): Promise<HookTypeError[]>;
37
+ //# sourceMappingURL=typecheck-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck-hooks.d.ts","sourceRoot":"","sources":["../../src/validation/typecheck-hooks.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAaxD,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG;IAC1B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAmE1B"}
@@ -0,0 +1,169 @@
1
+ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { join, relative } from 'node:path';
4
+ import ts from 'typescript';
5
+ import { HOOKS_API_FILE, REQUEST_TYPES_FILE, } from '../generation/types/generate-type-surface.js';
6
+ import { toTypeScriptPath, tsPathRelativeTo } from '../ts-path.js';
7
+ import { entryExists } from '../utils.js';
8
+ import { sharedCompilerHost } from './shared-compiler-host.js';
9
+ /**
10
+ * TS18003, "No inputs were found in config file".
11
+ *
12
+ * Raised against the tsconfig's own `include`, which this check never compiles
13
+ * by — the roots are passed to `createProgram` explicitly.
14
+ */
15
+ const NO_INPUTS_FOUND = 18003;
16
+ /**
17
+ * Type-check the user's hooks against a **freshly generated** surface.
18
+ *
19
+ * The fresh surface, not the committed one: the question `validate` answers is
20
+ * whether the hooks still fit the API description as it is now. Comparing
21
+ * against what is committed would only tell the user whether they had run
22
+ * `sync`, which is the other half of the gate.
23
+ *
24
+ * The surface is written to a temporary directory, so the check never
25
+ * disturbs what is committed — a `validate` that rewrote `generated/` would
26
+ * make `sync --check` pass by having run.
27
+ *
28
+ * The user's own tsconfig supplies the compiler options where it exists,
29
+ * because their hooks are written under those settings. `paths` is *merged*,
30
+ * not replaced: the `@thymian/hooks` alias is added as an **absolute**
31
+ * mapping (to the scratch surface), which TypeScript resolves ahead of
32
+ * `baseUrl` regardless of what the user set it to — see
33
+ * {@link mergeHooksAlias}. A hooks author with their own extra `paths`
34
+ * aliases gets the same resolution their editor gives them; replacing the
35
+ * whole map, as this once did, silently broke every alias the user added.
36
+ */
37
+ export async function typecheckHooks(paths, surface, hookFiles) {
38
+ const { options: userOptions, diagnostics: tsconfigDiagnostics } = await userCompilerOptions(paths);
39
+ if (hookFiles.length === 0) {
40
+ // Nothing to compile, but a malformed tsconfig is still worth reporting —
41
+ // that is the whole point of not falling back to defaults silently.
42
+ return tsconfigDiagnostics.map((diagnostic) => toHookTypeError(diagnostic, paths.root));
43
+ }
44
+ const scratch = await mkdtemp(join(tmpdir(), 'thymian-validate-'));
45
+ const generated = join(scratch, 'generated');
46
+ try {
47
+ await mkdir(generated, { recursive: true });
48
+ await writeFile(join(generated, REQUEST_TYPES_FILE), surface.requestTypes, 'utf-8');
49
+ await writeFile(join(generated, HOOKS_API_FILE), surface.hooksApi, 'utf-8');
50
+ const compilerOptions = {
51
+ ...userOptions,
52
+ noEmit: true,
53
+ paths: mergeHooksAlias(userOptions.paths, join(generated, HOOKS_API_FILE)),
54
+ };
55
+ // TypeScript files only. A `.js`/`.mjs`/`.cjs` hook is legal — the loader
56
+ // runs it, and `transaction-filter.ts` documents that such a file is
57
+ // simply not type-checked — but handed to `createProgram` without
58
+ // `allowJs` it becomes TS6504, a program-level diagnostic with no file of
59
+ // its own, which lands on `tsconfig.json:1:1` and renders `broken`. A hook
60
+ // that runs fine cannot fail the type gate.
61
+ const program = ts.createProgram(hookFiles
62
+ .filter((file) => /\.[cm]?ts$/.test(file))
63
+ .map((file) => join(paths.hooksDir, file)), compilerOptions, sharedCompilerHost(compilerOptions));
64
+ // `scratch` is a `node:path` value (backslashes on Windows);
65
+ // `diagnostic.file.fileName` is TypeScript's own forward-slashed form.
66
+ // `tsPathRelativeTo` normalizes both, so this excludes a scratch-surface
67
+ // diagnostic on every platform — a raw `startsWith` never matched on
68
+ // Windows, and every one of these diagnostics leaked through.
69
+ const diagnostics = [
70
+ ...tsconfigDiagnostics,
71
+ ...ts.getPreEmitDiagnostics(program),
72
+ ].filter((diagnostic) => !diagnostic.file ||
73
+ tsPathRelativeTo(diagnostic.file.fileName, scratch) === undefined);
74
+ return diagnostics.map((diagnostic) => toHookTypeError(diagnostic, paths.root));
75
+ }
76
+ finally {
77
+ await rm(scratch, { recursive: true, force: true });
78
+ }
79
+ }
80
+ /**
81
+ * One `ts.Diagnostic`, in the shape `validate`'s callers read.
82
+ *
83
+ * A diagnostic with no `file` is about the *options* rather than a source
84
+ * file — a malformed tsconfig, an unresolvable `types` entry — and is
85
+ * attributed to `tsconfig.json` rather than dropped. Dropping these is what
86
+ * made a broken tsconfig fail silently and report a clean bill of health.
87
+ */
88
+ function toHookTypeError(diagnostic, root) {
89
+ const file = diagnostic.file;
90
+ if (!file) {
91
+ return {
92
+ file: 'tsconfig.json',
93
+ line: 1,
94
+ column: 1,
95
+ message: ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '),
96
+ code: diagnostic.code,
97
+ };
98
+ }
99
+ const { line, character } = file.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
100
+ return {
101
+ file: relative(root, file.fileName),
102
+ line: line + 1,
103
+ column: character + 1,
104
+ message: ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '),
105
+ code: diagnostic.code,
106
+ };
107
+ }
108
+ /**
109
+ * The user's own `paths`, plus `@thymian/hooks` pointed at the fresh surface
110
+ * as an absolute mapping.
111
+ *
112
+ * TypeScript resolves a rooted (absolute) `paths` entry ahead of `baseUrl` —
113
+ * `combinePaths` returns the rooted candidate outright — so this alias
114
+ * resolves to the scratch surface no matter what the user's `baseUrl` is, or
115
+ * whether they set one at all. That is what lets the rest of the user's
116
+ * `paths` keep resolving under *their* `baseUrl`, unreplaced.
117
+ */
118
+ function mergeHooksAlias(userPaths, hooksApiFile) {
119
+ return {
120
+ ...userPaths,
121
+ '@thymian/hooks': [toTypeScriptPath(hooksApiFile)],
122
+ };
123
+ }
124
+ /**
125
+ * The compiler options the user's own sampler tsconfig sets, or the defaults
126
+ * `init` would have scaffolded — plus whatever the tsconfig itself failed to
127
+ * read or parse, as diagnostics rather than a swallowed error.
128
+ *
129
+ * A tsconfig the user has edited is the whole reason `init` writes it once, so
130
+ * `validate` has to honour it — including a `strict: false` a user chose. A
131
+ * tsconfig that fails outright still yields the fallback options, so a typo
132
+ * elsewhere in the hooks is not masked by an unrelated config error — but the
133
+ * config error itself is never dropped.
134
+ */
135
+ async function userCompilerOptions(paths) {
136
+ const fallback = {
137
+ strict: true,
138
+ module: ts.ModuleKind.NodeNext,
139
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
140
+ target: ts.ScriptTarget.ES2023,
141
+ skipLibCheck: true,
142
+ };
143
+ if (!(await entryExists(paths.tsconfigPath))) {
144
+ return { options: fallback, diagnostics: [] };
145
+ }
146
+ // Normalized before it reaches TypeScript, which compares the name it is
147
+ // given against the forward-slashed one it derives for the diagnostic's
148
+ // source file. Handed a `node:path` value, that comparison is an internal
149
+ // assertion failure on Windows — and only when a diagnostic exists at all,
150
+ // so a malformed tsconfig crashed where a valid one was fine.
151
+ const tsconfigPath = toTypeScriptPath(paths.tsconfigPath);
152
+ const read = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
153
+ if (read.error) {
154
+ return { options: fallback, diagnostics: [read.error] };
155
+ }
156
+ const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, toTypeScriptPath(paths.root), undefined, tsconfigPath);
157
+ return {
158
+ options: { ...fallback, ...parsed.options },
159
+ // TS18003 ("No inputs were found in config file") is not a fault of the
160
+ // user's tsconfig: the scaffolded `include` names `hooks/**/*.ts` and
161
+ // `generated/**/*.d.ts`, and a sampler directory with neither yet is the
162
+ // ordinary state right after `sampler init`. Reported, it renders the
163
+ // whole surface `broken` at `tsconfig.json:1:1` over an empty hooks tree.
164
+ // What actually compiles is decided by the root files passed to
165
+ // `createProgram` below, never by this `include`.
166
+ diagnostics: parsed.errors.filter((diagnostic) => diagnostic.code !== NO_INPUTS_FOUND),
167
+ };
168
+ }
169
+ //# sourceMappingURL=typecheck-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck-hooks.js","sourceRoot":"","sources":["../../src/validation/typecheck-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,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E,CAAC;IAChD,CAAC;IAED,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,2EAA2E;IAC3E,8DAA8D;IAC9D,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,EAAE,CAAC,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE9D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAC1C,IAAI,CAAC,MAAM,EACX,EAAE,CAAC,GAAG,EACN,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAC5B,SAAS,EACT,YAAY,CACb,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE;QAC3C,wEAAwE;QACxE,sEAAsE;QACtE,yEAAyE;QACzE,sEAAsE;QACtE,0EAA0E;QAC1E,gEAAgE;QAChE,kDAAkD;QAClD,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAC/B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,eAAe,CACpD;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { type TypeSurface } from '../generation/types/generate-type-surface.js';
2
+ import type { HookDiagnostic } from '../hooks/hook-diagnostics.js';
3
+ import { type LoadUserHooksResult } from '../hooks/load-user-hooks.js';
4
+ import type { SamplerPaths } from '../sampler-paths.js';
5
+ import type { TransactionCatalog } from '../selectors/transaction-catalog.js';
6
+ import { type HookTypeError } from './typecheck-hooks.js';
7
+ /**
8
+ * How the committed surface stands against the description as it is now.
9
+ *
10
+ * - `absent` — nothing is committed, so there is nothing to be behind. `init`
11
+ * has not been run, which is a legitimate state.
12
+ * - `in-sync` — canonicalized, the committed files say what a fresh generation
13
+ * would say.
14
+ * - `behind` — they differ. Whether that matters is the type check's answer,
15
+ * not this one's.
16
+ */
17
+ export type SurfaceState = 'absent' | 'in-sync' | 'behind';
18
+ export type ValidationReport = {
19
+ surface: SurfaceState;
20
+ /** Generated files whose canonical form differs, relative to `generated/`. */
21
+ changedFiles: string[];
22
+ /** What `tsc` says about the hooks, against the fresh surface. */
23
+ typeErrors: HookTypeError[];
24
+ /** Hooks whose target resolves to nothing. */
25
+ unresolved: HookDiagnostic[];
26
+ /** Hooks that resolve but cannot both apply. */
27
+ conflicts: HookDiagnostic[];
28
+ /** Hooks created but never exported, so nothing can reach them. */
29
+ unexported: HookDiagnostic[];
30
+ /** Non-fatal things the scan could not do. */
31
+ warnings: string[];
32
+ /**
33
+ * What to tell the user, and what to tell them to do about it.
34
+ *
35
+ * Named `verdict` rather than `outcome`: an `Outcome` is what one Transaction
36
+ * earns in a `sampler check` run, and `check --json` emits that under the
37
+ * name. This is a judgement about the committed surface and the hooks as a
38
+ * whole, so one word cannot carry both without two `--json` surfaces
39
+ * disagreeing about what it means.
40
+ *
41
+ * - `ok` — nothing to say.
42
+ * - `stale` — the committed types are behind the description but every hook
43
+ * still compiles. A **warning**: run `sync`.
44
+ * - `drifted` — the committed types are behind **and** a hook no longer fits.
45
+ * The description moved: `sync`, then fix the hooks.
46
+ * - `broken` — a hook does not compile, or a target resolves to nothing,
47
+ * while the committed types are in sync. Nothing has drifted, so `sync` is
48
+ * *not* the remedy — it would rewrite files that are already correct and
49
+ * leave the real error in place. Only the hooks need fixing.
50
+ *
51
+ * The last two were one verdict, which meant a plain type error in a hook
52
+ * was announced as "the API description no longer matches these hooks" and
53
+ * answered with a command that could not help.
54
+ */
55
+ verdict: 'ok' | 'stale' | 'drifted' | 'broken';
56
+ };
57
+ /** Which committed files differ from a fresh generation, canonically. */
58
+ export declare function changedFiles(committed: Record<string, string>, surface: TypeSurface): string[];
59
+ /**
60
+ * The whole gate: is the committed surface current, and do the hooks still fit
61
+ * the description?
62
+ *
63
+ * The two questions are deliberately separate. "Behind" is about a file the
64
+ * user has to regenerate; "broken" is about a hook the user has to fix. Only
65
+ * the second can fail a build on its own, which is what makes a generator
66
+ * change a warning rather than a wall.
67
+ */
68
+ export declare function validateSampler(paths: SamplerPaths, catalog: TransactionCatalog,
69
+ /**
70
+ * The hooks the `core.format` handler already loaded.
71
+ *
72
+ * Passed through rather than re-loaded: `loadUserHooks` evaluates every hook
73
+ * file *and everything it imports* afresh per scan. Loading twice per
74
+ * `validate` ran the user's module side effects twice for no new
75
+ * information. Optional so a caller with
76
+ * no loaded result — a test, a future command — still gets a correct report.
77
+ */
78
+ loaded?: LoadUserHooksResult): Promise<ValidationReport>;
79
+ //# sourceMappingURL=validate-sampler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-sampler.d.ts","sourceRoot":"","sources":["../../src/validation/validate-sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,8CAA8C,CAAC;AAMtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,kEAAkE;IAClE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,8CAA8C;IAC9C,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,gDAAgD;IAChD,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,mEAAmE;IACnE,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;CAChD,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,OAAO,EAAE,WAAW,GACnB,MAAM,EAAE,CAgBV;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,kBAAkB;AAC3B;;;;;;;;GAQG;AACH,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAuD3B"}
@@ -0,0 +1,89 @@
1
+ import { generateTypeSurface, } from '../generation/types/generate-type-surface.js';
2
+ import { selfCheckSurface } from '../generation/types/self-check-surface.js';
3
+ import { readGenerated, surfaceAsFiles, } from '../generation/types/write-type-surface.js';
4
+ import { loadUserHooks, } from '../hooks/load-user-hooks.js';
5
+ import { sameSurface } from './canonicalize.js';
6
+ import { typecheckHooks } from './typecheck-hooks.js';
7
+ /** Which committed files differ from a fresh generation, canonically. */
8
+ export function changedFiles(committed, surface) {
9
+ const fresh = surfaceAsFiles(surface);
10
+ const names = [
11
+ ...new Set([...Object.keys(committed), ...Object.keys(fresh)]),
12
+ ].sort();
13
+ return names.filter((name) => {
14
+ const before = committed[name];
15
+ const after = fresh[name];
16
+ if (before === undefined || after === undefined) {
17
+ return true;
18
+ }
19
+ return !sameSurface(before, after);
20
+ });
21
+ }
22
+ /**
23
+ * The whole gate: is the committed surface current, and do the hooks still fit
24
+ * the description?
25
+ *
26
+ * The two questions are deliberately separate. "Behind" is about a file the
27
+ * user has to regenerate; "broken" is about a hook the user has to fix. Only
28
+ * the second can fail a build on its own, which is what makes a generator
29
+ * change a warning rather than a wall.
30
+ */
31
+ export async function validateSampler(paths, catalog,
32
+ /**
33
+ * The hooks the `core.format` handler already loaded.
34
+ *
35
+ * Passed through rather than re-loaded: `loadUserHooks` evaluates every hook
36
+ * file *and everything it imports* afresh per scan. Loading twice per
37
+ * `validate` ran the user's module side effects twice for no new
38
+ * information. Optional so a caller with
39
+ * no loaded result — a test, a future command — still gets a correct report.
40
+ */
41
+ loaded) {
42
+ const surface = await generateTypeSurface(catalog);
43
+ // The self-check gate, on `validate`'s own scratch surface. Deliberately
44
+ // thrown rather than folded into `ValidationReport` — the one place this
45
+ // function does not hold to "record, don't throw": every other finding
46
+ // here (`typeErrors`, `unresolved`, `conflicts`, `unexported`) is a
47
+ // question about the user's hooks or API description, which is exactly
48
+ // what a `verdict` and its fields exist to describe. A surface that fails
49
+ // its own self-check is neither — it is a defect in the sampler's
50
+ // generator, present regardless of what the user wrote, and none of this
51
+ // report's verdicts (`ok`/`stale`/`drifted`/`broken`) has a sentence for
52
+ // "the sampler is broken." `init` and `sync` abort the same way at the
53
+ // same seam, and the gate is only meaningful if it behaves identically
54
+ // everywhere a fresh surface is produced.
55
+ await selfCheckSurface(surface);
56
+ const committed = await readGenerated(paths);
57
+ const hooks = loaded ?? (await loadUserHooks(paths.hooksDir, catalog));
58
+ const typeErrors = await typecheckHooks(paths, surface, hooks.files);
59
+ // Computed once. The comparison walks every committed file through the
60
+ // canonicalizer, and the answer is needed twice — for the state and for the
61
+ // report.
62
+ const changed = changedFiles(committed, surface);
63
+ const state = Object.keys(committed).length === 0
64
+ ? 'absent'
65
+ : changed.length === 0
66
+ ? 'in-sync'
67
+ : 'behind';
68
+ const broken = typeErrors.length > 0 ||
69
+ hooks.diagnostics.length > 0 ||
70
+ hooks.conflicts.length > 0 ||
71
+ hooks.unexported.length > 0;
72
+ return {
73
+ surface: state,
74
+ changedFiles: state === 'behind' ? changed : [],
75
+ typeErrors,
76
+ unresolved: [...hooks.diagnostics],
77
+ conflicts: [...hooks.conflicts],
78
+ unexported: [...hooks.unexported],
79
+ warnings: [...hooks.warnings],
80
+ verdict: broken
81
+ ? state === 'behind'
82
+ ? 'drifted'
83
+ : 'broken'
84
+ : state === 'behind'
85
+ ? 'stale'
86
+ : 'ok',
87
+ };
88
+ }
89
+ //# sourceMappingURL=validate-sampler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-sampler.js","sourceRoot":"","sources":["../../src/validation/validate-sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACL,aAAa,GAEd,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAsB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAsD1E,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAC1B,SAAiC,EACjC,OAAoB;IAEpB,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG;QACZ,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KAC/D,CAAC,IAAI,EAAE,CAAC;IAET,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CA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,GAAG,CAAC;QACrB,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAC5B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QAC1B,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IAE9B,OAAO;QACL,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC/C,UAAU;QACV,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;QAClC,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;QAC/B,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;QACjC,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC7B,OAAO,EAAE,MAAM;YACb,CAAC,CAAC,KAAK,KAAK,QAAQ;gBAClB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,QAAQ;YACZ,CAAC,CAAC,KAAK,KAAK,QAAQ;gBAClB,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,IAAI;KACX,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thymian/plugin-sampler",
3
- "version": "0.3.0-canary.20261007-e6cb8dc",
3
+ "version": "0.3.0-canary.20261007-cdbe1d3",
4
4
  "description": "Thymian plugin for generating HTTP request samples from API descriptions",
5
5
  "license": "AGPL-3.0-only",
6
6
  "bugs": {
@@ -44,16 +44,14 @@
44
44
  "!**/*.tsbuildinfo"
45
45
  ],
46
46
  "dependencies": {
47
- "@scalar/json-magic": "^0.9.0",
48
- "@thymian/common-cli": "0.3.0-canary.20261007-e6cb8dc",
49
- "@thymian/core": "0.3.0-canary.20261007-e6cb8dc",
50
- "@thymian/plugin-request-dispatcher": "0.3.0-canary.20261007-e6cb8dc",
51
- "code-block-writer": "^13.0.3",
47
+ "@thymian/common-cli": "0.3.0-canary.20261007-cdbe1d3",
48
+ "@thymian/core": "0.3.0-canary.20261007-cdbe1d3",
49
+ "@thymian/plugin-request-dispatcher": "0.3.0-canary.20261007-cdbe1d3",
52
50
  "jiti": "^2.6.1",
53
51
  "json-schema-to-typescript": "^15.0.4",
54
- "launch-editor": "^2.14.1",
55
52
  "openapi-sampler": "^1.7.2",
56
- "tslib": "^2.3.0"
53
+ "tslib": "^2.3.0",
54
+ "typescript": "^5.9.2"
57
55
  },
58
56
  "oclif": {
59
57
  "commands": "./dist/cli/commands",
@@ -66,8 +64,6 @@
66
64
  }
67
65
  },
68
66
  "devDependencies": {
69
- "@thymian/core-testing": "0.3.0-canary.20261007-e6cb8dc",
70
- "fast-json-stable-stringify": "^2.1.0",
71
- "ts-morph": "^27.0.2"
67
+ "@thymian/core-testing": "0.3.0-canary.20261007-cdbe1d3"
72
68
  }
73
69
  }
@@ -1,10 +0,0 @@
1
- import { BaseCliRunCommand } from '@thymian/common-cli';
2
- export default class GenerateHook extends BaseCliRunCommand<typeof GenerateHook> {
3
- static aliases: string[];
4
- static description: string;
5
- static flags: {
6
- 'for-transaction': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- };
8
- run(): Promise<void>;
9
- }
10
- //# sourceMappingURL=hook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/generate/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB,CACzD,OAAO,YAAY,CACpB;IACC,OAAgB,OAAO,WAAyC;IAChE,OAAgB,WAAW,SAC6B;IAExD,OAAgB,KAAK;;MAKnB;IAEa,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
@@ -1,19 +0,0 @@
1
- import { BaseCliRunCommand } from '@thymian/common-cli';
2
- import { Flags } from '@thymian/common-cli/oclif';
3
- import { generateHook } from '../../../generate-hook.js';
4
- export default class GenerateHook extends BaseCliRunCommand {
5
- static aliases = ['sampler g h', 'sampler generate h'];
6
- static description = 'Generate a sampler hook for a specific transaction.';
7
- static flags = {
8
- 'for-transaction': Flags.string({
9
- description: 'Transaction identifier to generate the hook for.',
10
- required: false,
11
- }),
12
- };
13
- async run() {
14
- await this.thymian.run(async (emitter) => {
15
- await generateHook(this.thymian, emitter, this, this.flags.cwd, this.flags['validate-specs'], this.flags['for-transaction']);
16
- });
17
- }
18
- }
19
- //# sourceMappingURL=hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/generate/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAEzC;IACC,MAAM,CAAU,OAAO,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAChE,MAAM,CAAU,WAAW,GACzB,qDAAqD,CAAC;IAExD,MAAM,CAAU,KAAK,GAAG;QACtB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC9B,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC;IAEO,KAAK,CAAC,GAAG;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvC,MAAM,YAAY,CAChB,IAAI,CAAC,OAAO,EACZ,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAC5B,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -1,4 +0,0 @@
1
- import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
2
- import { type Thymian, type ThymianEmitter, type ThymianFormat } from '@thymian/core';
3
- export declare function generateHook<T extends typeof oclif.Command = typeof oclif.Command>(thymian: Thymian, emitter: ThymianEmitter, command: BaseCliRunCommand<T>, cwd: string, validateSpecs: boolean, forTransaction?: string, loadedThymianFormat?: ThymianFormat): Promise<void>;
4
- //# sourceMappingURL=generate-hook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-hook.d.ts","sourceRoot":"","sources":["../../src/cli/generate-hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAW,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAGnB,MAAM,eAAe,CAAC;AASvB,wBAAsB,YAAY,CAChC,CAAC,SAAS,OAAO,KAAK,CAAC,OAAO,GAAG,OAAO,KAAK,CAAC,OAAO,EAErD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,OAAO,EACtB,cAAc,CAAC,EAAE,MAAM,EACvB,mBAAmB,CAAC,EAAE,aAAa,GAClC,OAAO,CAAC,IAAI,CAAC,CAqHf"}
@@ -1,96 +0,0 @@
1
- import { writeFile } from 'node:fs/promises';
2
- import { format, join, relative } from 'node:path';
3
- import { BaseCliRunCommand, oclif, prompts } from '@thymian/common-cli';
4
- import { ThymianBaseError, thymianHttpTransactionToString, } from '@thymian/core';
5
- import launchEditor from 'launch-editor';
6
- import { afterEachRequestHook, authorizeHook, beforeEachRequestHook, } from './templates.js';
7
- export async function generateHook(thymian, emitter, command, cwd, validateSpecs, forTransaction, loadedThymianFormat) {
8
- const thymianFormat = loadedThymianFormat ??
9
- (await thymian.loadFormat({
10
- inputs: [],
11
- validateSpecs,
12
- }));
13
- const titleToTransaction = new Map();
14
- for (const t of thymianFormat.getThymianHttpTransactions()) {
15
- titleToTransaction.set(thymianHttpTransactionToString(t.thymianReq, t.thymianRes), t);
16
- }
17
- const transactions = [...titleToTransaction.keys()].map((title) => ({
18
- name: title,
19
- value: title,
20
- }));
21
- let transaction;
22
- if (!forTransaction) {
23
- const result = await prompts.search({
24
- message: 'For which transaction do you want to generate a hook?',
25
- source: (answersSoFar) => {
26
- if (typeof answersSoFar === 'undefined') {
27
- return transactions;
28
- }
29
- return transactions.filter((t) => t.value.toLowerCase().includes(answersSoFar.toLowerCase()));
30
- },
31
- });
32
- transaction = titleToTransaction.get(result);
33
- }
34
- else {
35
- transaction = thymianFormat.getThymianHttpTransactionById(forTransaction);
36
- }
37
- if (!transaction) {
38
- throw new ThymianBaseError('Invalid transaction selected.', {
39
- name: 'InvalidTransactionError',
40
- ref: 'https://thymian.dev/references/errors/invalid-transaction-error/',
41
- });
42
- }
43
- const path = await emitter.emitAction('sampler.path-from-transaction', {
44
- transactionId: transaction.transactionId,
45
- }, {
46
- strategy: 'first',
47
- });
48
- if (path) {
49
- const relativePath = relative(cwd, path);
50
- const answer = await prompts.confirm({
51
- message: `Do you want to generate a hook file at ${oclif.ux.colorize('bold', oclif.ux.colorize('underline', relativePath))}?`,
52
- default: true,
53
- });
54
- if (answer) {
55
- const choice = await prompts.select({
56
- message: 'When do you want to execute the hook?',
57
- choices: ['Before each request', 'After each response', 'Authorize'],
58
- });
59
- const fileName = Math.random().toString(36).slice(2, 7);
60
- const dir = join(path, '..');
61
- const suffix = choice === 'After each response'
62
- ? 'afterEach'
63
- : choice === 'Before each request'
64
- ? 'beforeEach'
65
- : 'authorize';
66
- const fullFilePath = format({
67
- dir,
68
- name: `${fileName}.${suffix}`,
69
- ext: '.ts',
70
- });
71
- if (choice === 'After each response') {
72
- await writeFile(fullFilePath, afterEachRequestHook);
73
- }
74
- else if (choice === 'Authorize') {
75
- await writeFile(fullFilePath, authorizeHook);
76
- }
77
- else {
78
- await writeFile(fullFilePath, beforeEachRequestHook);
79
- }
80
- command.log(oclif.ux.colorize('green', 'Hook generated successfully!'));
81
- const openInEditor = await prompts.confirm({
82
- message: `Do you want to open the file in your editor now?`,
83
- default: true,
84
- });
85
- if (openInEditor) {
86
- launchEditor(fullFilePath, 'webstorm', (_, errorMessage) => {
87
- if (errorMessage) {
88
- command.error(errorMessage);
89
- }
90
- command.log('Opening file in editor.');
91
- });
92
- }
93
- }
94
- }
95
- }
96
- //# sourceMappingURL=generate-hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-hook.js","sourceRoot":"","sources":["../../src/cli/generate-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAEL,gBAAgB,EAIhB,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,OAAgB,EAChB,OAAuB,EACvB,OAA6B,EAC7B,GAAW,EACX,aAAsB,EACtB,cAAuB,EACvB,mBAAmC;IAEnC,MAAM,aAAa,GACjB,mBAAmB;QACnB,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC;YACxB,MAAM,EAAE,EAAE;YACV,aAAa;SACd,CAAC,CAAC,CAAC;IAEN,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkC,CAAC;IAErE,KAAK,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,CAAC,CAAC;YACtD,CAAC;iBAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,MAAM,SAAS,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,MAAM,SAAS,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC,CAAC;YAExE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC;gBACzC,OAAO,EAAE,kDAAkD;gBAC3D,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CAAC;gBACjB,YAAY,CAAC,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE;oBACzD,IAAI,YAAY,EAAE,CAAC;wBACjB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBAC9B,CAAC;oBAED,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const beforeEachRequestHook = "import * as Hooks from '@thymian/hooks';\n\nconst hook: Hooks.BeforeEachRequestHook = async (request, context, utils) => {\n\n return request;\n}\n\nexport default hook;\n";
2
- export declare const afterEachRequestHook = "import * as Hooks from '@thymian/hooks';\n\nconst hook: Hooks.AfterEachRequestHook = async (response, context, utils) => {\n\n return response;\n}\n\nexport default hook;\n";
3
- export declare const authorizeHook = "import * as Hooks from '@thymian/hooks';\n\nconst hook: Hooks.AuthorizeHook = async (request, context, utils) => {\n\n return request;\n}\n\nexport default hook;\n";
4
- //# sourceMappingURL=templates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/cli/templates.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,iLAQjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,kLAQhC,CAAC;AAEF,eAAO,MAAM,aAAa,yKAQzB,CAAC"}
@@ -1,28 +0,0 @@
1
- export const beforeEachRequestHook = `import * as Hooks from '@thymian/hooks';
2
-
3
- const hook: Hooks.BeforeEachRequestHook = async (request, context, utils) => {
4
-
5
- return request;
6
- }
7
-
8
- export default hook;
9
- `;
10
- export const afterEachRequestHook = `import * as Hooks from '@thymian/hooks';
11
-
12
- const hook: Hooks.AfterEachRequestHook = async (response, context, utils) => {
13
-
14
- return response;
15
- }
16
-
17
- export default hook;
18
- `;
19
- export const authorizeHook = `import * as Hooks from '@thymian/hooks';
20
-
21
- const hook: Hooks.AuthorizeHook = async (request, context, utils) => {
22
-
23
- return request;
24
- }
25
-
26
- export default hook;
27
- `;
28
- //# sourceMappingURL=templates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/cli/templates.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;CAQpC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;CAQnC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;CAQ5B,CAAC"}