@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,11 +1,13 @@
1
1
  import { sample } from 'openapi-sampler';
2
+ import { closedObjectsToBoolean } from '../closed-schema.js';
2
3
  export class JsonContentTypeStrategy {
3
4
  matches(contentType) {
4
5
  return /^application\/[^+]*[+]?(json);?.*/.test(contentType);
5
6
  }
6
7
  async generate(schema) {
8
+ const closed = closedObjectsToBoolean(schema);
7
9
  return {
8
- $content: sample(schema, {}, schema),
10
+ $content: sample(closed, {}, closed),
9
11
  };
10
12
  }
11
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"json.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/json.content-type-strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC,MAAM,OAAO,uBAAuB;IAClC,OAAO,CAAC,WAAmB;QACzB,OAAO,mCAAmC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB;QAClC,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,MAAuB,EAAE,EAAE,EAAE,MAAM,CAAC;SACtD,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"json.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/json.content-type-strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,MAAM,OAAO,uBAAuB;IAClC,OAAO,CAAC,WAAmB;QACzB,OAAO,mCAAmC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB;QAClC,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAkB,CAAC;QAE/D,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC;SACrC,CAAC;IACJ,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"xml.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/xml.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,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAS9D"}
1
+ {"version":3,"file":"xml.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/xml.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,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAS9D"}
@@ -1,13 +1,15 @@
1
1
  import { sample } from 'openapi-sampler';
2
+ import { closedObjectsToBoolean } from '../closed-schema.js';
2
3
  export class XmlContentTypeStrategy {
3
4
  matches(contentType) {
4
5
  return /^application\/[^+]*[+]?(xml);?.*/.test(contentType);
5
6
  }
6
7
  async generate(schema) {
8
+ const closed = closedObjectsToBoolean(schema);
7
9
  return {
8
10
  $encoding: 'utf-8',
9
11
  $ext: 'xml',
10
- $buffer: Buffer.from(sample(schema, { format: 'xml' }, schema)),
12
+ $buffer: Buffer.from(sample(closed, { format: 'xml' }, closed)),
11
13
  };
12
14
  }
13
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"xml.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/xml.content-type-strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC,MAAM,OAAO,sBAAsB;IACjC,OAAO,CAAC,WAAmB;QACzB,OAAO,kCAAkC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB;QAClC,OAAO;YACL,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,MAAM,CAAC,IAAI,CAClB,MAAM,CAAC,MAAuB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,CAAW,CACrE;SACF,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"xml.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/xml.content-type-strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,MAAM,OAAO,sBAAsB;IACjC,OAAO,CAAC,WAAmB;QACzB,OAAO,kCAAkC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB;QAClC,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAkB,CAAC;QAE/D,OAAO;YACL,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,CAAW,CAAC;SAC1E,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { ThymianEmitter, ThymianFormat, ThymianHttpTransaction } from '@thymian/core';
2
+ import type { HttpRequestSample } from '../http-request-sample.js';
3
+ /**
4
+ * The one generator-selection site in the package: picks the request generator
5
+ * that matches a transaction and produces its single sample.
6
+ *
7
+ * A pure function of `(format, transaction)` — the same pair always yields the
8
+ * same sample, which is what lets the projection be rebuilt at will instead of
9
+ * being stored.
10
+ */
11
+ export declare function generateRequestSampleForTransaction(format: ThymianFormat, transaction: ThymianHttpTransaction, emitter: ThymianEmitter): Promise<HttpRequestSample>;
12
+ //# sourceMappingURL=generate-request-sample.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-request-sample.d.ts","sourceRoot":"","sources":["../../src/generation/generate-request-sample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAWnE;;;;;;;GAOG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAqB5B"}
@@ -1,4 +1,3 @@
1
- import { samplesTreeFromThymianHttpTransaction } from '../samples-structure/samples-from-transactions.js';
2
1
  import { ContentSourceGenerator } from './content-source-generator.js';
3
2
  import { HookContentTypeStrategy } from './content-type-strategies/hook.content-type-strategy.js';
4
3
  import { ImageContentTypeStrategy } from './content-type-strategies/image.content-type-strategy.js';
@@ -8,7 +7,15 @@ import { XmlContentTypeStrategy } from './content-type-strategies/xml.content-ty
8
7
  import { DefaultRequestGenerator } from './request-generators/default-request-generator.js';
9
8
  import { RangeRequestGenerator } from './request-generators/range-request-generator.js';
10
9
  import { UnauthorizedRequestGenerator } from './request-generators/unauthorized-request-generator.js';
11
- export async function generateSamplesTree(format, transaction, emitter) {
10
+ /**
11
+ * The one generator-selection site in the package: picks the request generator
12
+ * that matches a transaction and produces its single sample.
13
+ *
14
+ * A pure function of `(format, transaction)` — the same pair always yields the
15
+ * same sample, which is what lets the projection be rebuilt at will instead of
16
+ * being stored.
17
+ */
18
+ export async function generateRequestSampleForTransaction(format, transaction, emitter) {
12
19
  const contentGenerator = new ContentSourceGenerator([
13
20
  new JsonContentTypeStrategy(),
14
21
  new XmlContentTypeStrategy(),
@@ -21,6 +28,6 @@ export async function generateSamplesTree(format, transaction, emitter) {
21
28
  ];
22
29
  const generator = generators.find((g) => g.matches()) ??
23
30
  new DefaultRequestGenerator(format, transaction, contentGenerator);
24
- return samplesTreeFromThymianHttpTransaction(await generator.generate(), transaction, format.toHash());
31
+ return await generator.generate();
25
32
  }
26
- //# sourceMappingURL=generate-samples.js.map
33
+ //# sourceMappingURL=generate-request-sample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-request-sample.js","s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ACpC,CAAC"}
@@ -14,6 +14,20 @@ export declare class DefaultRequestGenerator {
14
14
  protected generateQueryParameters(): Promise<Record<string, ContentSource>>;
15
15
  protected generatePathParameters(): Promise<Record<string, ContentSource>>;
16
16
  protected generateCookies(): Promise<Record<string, ContentSource>>;
17
+ /**
18
+ * The spec-derived default for the `authorize` flag: does this request declare
19
+ * a security requirement?
20
+ *
21
+ * A transaction the format does not hold is treated as unsecured. That case is
22
+ * reachable — a transaction can arrive from outside the loaded format, through
23
+ * a nested seeding call or a sample asked for before any format was published
24
+ * — and `requestIsSecured` raises on an unknown request id rather than
25
+ * answering `false`. `getThymianHttpTransactionById` is the one lookup that
26
+ * answers a miss instead of raising, and an existing transaction edge implies
27
+ * its request node, so it is a precise guard rather than a swallowed error.
28
+ * Unsecured is also the safe default: authorization additionally requires a
29
+ * registered authorize hook.
30
+ */
17
31
  protected authorize(): boolean;
18
32
  protected getHttpMethod(): string;
19
33
  protected getPath(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"default-request-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/request-generators/default-request-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,qBAAa,uBAAuB;IAEhC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,sBAAsB;IACtD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB;gBAFxC,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,sBAAsB,EACnC,gBAAgB,EAAE,sBAAsB;IAG7D,OAAO,IAAI,OAAO;IAIZ,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAsB5C,SAAS,CAAC,kBAAkB,IAAI,OAAO;cAWvB,kBAAkB,CAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;cAazB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAsBzE,SAAS,CAAC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAI3E,SAAS,CAAC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAI1E,SAAS,CAAC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAInE,SAAS,CAAC,SAAS,IAAI,OAAO;IAI9B,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC,SAAS,CAAC,OAAO,IAAI,MAAM;IAI3B,SAAS,CAAC,SAAS,IAAI,MAAM;CAG9B"}
1
+ {"version":3,"file":"default-request-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/request-generators/default-request-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,qBAAa,uBAAuB;IAEhC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,sBAAsB;IACtD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB;gBAFxC,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,sBAAsB,EACnC,gBAAgB,EAAE,sBAAsB;IAG7D,OAAO,IAAI,OAAO;IAIZ,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAsB5C,SAAS,CAAC,kBAAkB,IAAI,OAAO;cAWvB,kBAAkB,CAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;cAazB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAsBzE,SAAS,CAAC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAI3E,SAAS,CAAC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAI1E,SAAS,CAAC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAInE;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,SAAS,IAAI,OAAO;IAU9B,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC,SAAS,CAAC,OAAO,IAAI,MAAM;IAI3B,SAAS,CAAC,SAAS,IAAI,MAAM;CAG9B"}
@@ -64,8 +64,25 @@ export class DefaultRequestGenerator {
64
64
  generateCookies() {
65
65
  return this.generateParameters(this.transaction.thymianReq.cookies);
66
66
  }
67
+ /**
68
+ * The spec-derived default for the `authorize` flag: does this request declare
69
+ * a security requirement?
70
+ *
71
+ * A transaction the format does not hold is treated as unsecured. That case is
72
+ * reachable — a transaction can arrive from outside the loaded format, through
73
+ * a nested seeding call or a sample asked for before any format was published
74
+ * — and `requestIsSecured` raises on an unknown request id rather than
75
+ * answering `false`. `getThymianHttpTransactionById` is the one lookup that
76
+ * answers a miss instead of raising, and an existing transaction edge implies
77
+ * its request node, so it is a precise guard rather than a swallowed error.
78
+ * Unsecured is also the safe default: authorization additionally requires a
79
+ * registered authorize hook.
80
+ */
67
81
  authorize() {
68
- return this.format.requestIsSecured(this.transaction.thymianReqId);
82
+ const known = this.format.getThymianHttpTransactionById(this.transaction.transactionId);
83
+ return known
84
+ ? this.format.requestIsSecured(this.transaction.thymianReqId)
85
+ : false;
69
86
  }
70
87
  getHttpMethod() {
71
88
  return this.transaction.thymianReq.method;
@@ -1 +1 @@
1
- {"version":3,"file":"default-request-generator.js","sourceRoot":"","sources":["../../../src/generation/request-generators/default-request-generator.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,uBAAuB;IAEb;IACA;IACA;IAHrB,YACqB,MAAqB,EACrB,WAAmC,EACnC,gBAAwC;QAFxC,WAAM,GAAN,MAAM,CAAe;QACrB,gBAAW,GAAX,WAAW,CAAwB;QACnC,qBAAgB,GAAhB,gBAAgB,CAAwB;IAC1D,CAAC;IAEJ,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,aAAa,GAAsB;YACvC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;YACxB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;YACpB,cAAc,EAAE,MAAM,IAAI,CAAC,sBAAsB,EAAE;YACnD,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;YAC3B,KAAK,EAAE,MAAM,IAAI,CAAC,uBAAuB,EAAE;YAC3C,OAAO,EAAE,MAAM,IAAI,CAAC,eAAe,EAAE;YACrC,OAAO,EAAE,MAAM,IAAI,CAAC,eAAe,EAAE;SACtC,CAAC;QAEF,IAAI,IAAI,CAAC,kBAAkB,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YAClE,aAAa,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CACvD,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,EACrC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CACjC,C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AU,EAAE,SAAS,EAAE,CAAC;YAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAClB,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS;aAChD,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,uBAAuB;QAC/B,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAC9E,CAAC;IAES,sBAAsB;QAC9B,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAC7E,CAAC;IAES,eAAe;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IAES,SAAS;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACrE,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC;IAC5C,CAAC;IAES,OAAO;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;IAC1C,CAAC;IAES,SAAS;QACjB,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAC7H,CAAC;CACF"}
1
+ {"version":3,"file":"default-request-generator.js","sourceRoot":"","sources":["../../../src/generation/request-generators/default-request-generator.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,uBAAuB;IAEb;IACA;IACA;IAHrB,YACqB,MAAqB,EACrB,WAAmC,EACnC,gBAAwC;QAFxC,WAAM,GAAN,MAAM,CAA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cAAc,CAAC,CAAC;IAC7E,CAAC;IAES,eAAe;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACO,SAAS;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,6BAA6B,CACrD,IAAI,CAAC,WAAW,CAAC,aAAa,CAC/B,CAAC;QAEF,OAAO,KAAK;YACV,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;YAC7D,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC;IAC5C,CAAC;IAES,OAAO;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;IAC1C,CAAC;IAES,SAAS;QACjB,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAC7H,CAAC;CACF"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The set of declarations the type surface emits, with one copy of each.
3
+ *
4
+ * `json-schema-to-typescript` compiles one schema at a time and each call
5
+ * returns a self-contained unit: the root declaration plus every named
6
+ * component it references. Two transactions that both reference `Astronaut`
7
+ * therefore arrive carrying their own copy of it — nine copies of it, on the
8
+ * demo description, and nine copies of `AstronautInput` and `LaunchInput`
9
+ * beside them.
10
+ *
11
+ * That is not merely noisy. It compiles only for as long as every duplicated
12
+ * component happens to be an `interface`, because identical interfaces merge; a
13
+ * component that compiles to a type ALIAS — an enum, a union, an array — is
14
+ * `TS2300: Duplicate identifier` the moment a second transaction references it.
15
+ * And the drift gate cannot see either, because it compiles hooks with
16
+ * `skipLibCheck: true`, which is exactly the flag that stops TypeScript from
17
+ * reporting errors inside a `.d.ts`.
18
+ *
19
+ * De-duplicating also keeps the committed diff proportionate: editing one
20
+ * component used to move as many lines as there are transactions using it.
21
+ */
22
+ /** One top-level declaration, under the name it declares. */
23
+ export type Declaration = {
24
+ readonly name: string;
25
+ readonly text: string;
26
+ };
27
+ /**
28
+ * Splits one `compile()` result into its top-level declarations.
29
+ *
30
+ * Safe on the emitter's output rather than on TypeScript in general: every
31
+ * top-level declaration begins at column zero and everything nested is
32
+ * indented, so a column-zero `export` line — or the `/**` opening the JSDoc
33
+ * block that belongs to it — is a boundary.
34
+ */
35
+ export declare function splitDeclarations(source: string): Declaration[];
36
+ export declare class DeclarationSet {
37
+ private readonly byName;
38
+ /**
39
+ * Every name that may not be handed to a new declaration as-is: every name
40
+ * already committed to {@link byName}, plus the {@link reserved} fixed
41
+ * roots the caller seeds the set with. A name can be in here without being
42
+ * in `byName` — a reserved root nothing has collided with yet — which is
43
+ * exactly what makes a reservation free to check and free of output: {@link
44
+ * all} only ever reads `byName`.
45
+ */
46
+ private readonly used;
47
+ /**
48
+ * For each ORIGINAL declaration name, the raw (pre-rename) text of every
49
+ * variant this set has already resolved a final name for — whether that
50
+ * final name is the bare name itself (the non-conflict branch) or a
51
+ * renamed alias (the conflict branch).
52
+ *
53
+ * What makes this safe to reuse across separate `add()` calls: two
54
+ * declarations that share both a name and byte-identical text are the same
55
+ * declaration by this set's own definition of "conflict" (`text !==
56
+ * text`), so pointing a later occurrence at an earlier resolution is never
57
+ * a merge of two DIFFERENT things — only ever the same thing recognized
58
+ * twice. Keyed by the RAW text (before this call's renames are applied),
59
+ * because every occurrence of, say, a `Status`-named component carries that
60
+ * same raw form regardless of which final name it ends up resolving to —
61
+ * that is the one constant a repeat occurrence can be recognized by.
62
+ *
63
+ * Without this, a component that conflicts with a fixed root — or with
64
+ * another document's differently-bodied same-named component — mints a
65
+ * FRESH suffix every single time it recurs (`Status_2`, `Status_3`, …one
66
+ * per referencing transaction), because the conflict branch used to treat
67
+ * every conflicting unit as unprecedented. That defeats the set's own
68
+ * purpose: "one declaration per component" is exactly the guarantee this
69
+ * index restores for the conflict branch, matching what the non-conflict
70
+ * branch already gives for free.
71
+ */
72
+ private readonly resolved;
73
+ /**
74
+ * The renameable identifiers of every declaration text this set has seen,
75
+ * so a component that recurs in forty units — the demo description's
76
+ * shape — is parsed once, not forty times.
77
+ */
78
+ private readonly identifiersByText;
79
+ /**
80
+ * @param reserved the fixed root names {@link NameRegistry} mints around
81
+ * the generated declarations — `Status`, `Method`, `Endpoints` and the
82
+ * rest. A component whose OWN name collides with one of these can never be
83
+ * merged into it (they are never the same declaration), so a reservation
84
+ * has to force the conflict branch even though nothing with that name has
85
+ * been committed yet. Sharing the exact list `NameRegistry` was
86
+ * constructed with is what keeps the two reservations from drifting apart.
87
+ */
88
+ constructor(reserved?: Iterable<string>);
89
+ /** Records that `originalName`/`variant` resolved to `finalName`, and commits `finalName`/`finalText` as held. */
90
+ private commit;
91
+ /**
92
+ * Adds one compiled unit and returns the name its root ended up with.
93
+ *
94
+ * A unit whose declarations are all either new or byte-identical to what is
95
+ * already held is merged into it, which is the case every single-document
96
+ * description produces: one `$defs` name is one schema, so every copy of
97
+ * `Astronaut` is the same `Astronaut`.
98
+ *
99
+ * A unit that genuinely conflicts is given fresh names for **all** of its
100
+ * declarations rather than only the conflicting ones. Renaming part of a
101
+ * unit would leave the rest sharing declarations with whichever unit got
102
+ * there first, and "this component is the one my own root was compiled
103
+ * against" is the property worth keeping. Two shapes reach this branch:
104
+ * same component name, different body — which two separate description
105
+ * files can both declare — and a component named after one of the fixed
106
+ * roots this set was seeded with, which is a conflict on sight because a
107
+ * user's component and the surface's own `Status` are never the same
108
+ * declaration.
109
+ *
110
+ * "Fresh" does not mean "unconditionally new", though: {@link resolved}
111
+ * recognizes a (name, text) pair this set has already renamed once and
112
+ * reuses that name rather than minting another alias for it, so a
113
+ * component that conflicts with a fixed root — or with another document's
114
+ * component of the same name — is still deduplicated across every site
115
+ * that declares it identically, exactly as a non-conflicting component
116
+ * already is.
117
+ */
118
+ add(unit: readonly Declaration[], rootName: string): string;
119
+ /** Every declaration held, in name order. */
120
+ all(): string[];
121
+ private identifiersOf;
122
+ private freeName;
123
+ }
124
+ //# sourceMappingURL=declaration-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-set.d.ts","sourceRoot":"","sources":["../../../src/generation/types/declaration-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAkC/D;AA4ND,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IACnE;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwC;IAE1E;;;;;;;;OAQG;gBACS,QAAQ,GAAE,QAAQ,CAAC,MAAM,CAAM;IAI3C,kHAAkH;IAClH,OAAO,CAAC,MAAM;IAmBd;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAgE3D,6CAA6C;IAC7C,GAAG,IAAI,MAAM,EAAE;IAMf,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,QAAQ;CAgBjB"}