@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,22 +0,0 @@
1
- import { mergeHooks } from '../samples-structure/merge-tree.js';
2
- import { nodeIsType, } from '../samples-structure/samples-tree-structure.js';
3
- import { traverse } from '../samples-structure/traverse.js';
4
- export function loadHooksFromSamples(samples) {
5
- const result = new Map();
6
- traverse(samples, {
7
- afterEachResponse: [],
8
- authorize: [],
9
- beforeEachRequest: [],
10
- }, (node, hooks) => {
11
- let nextHooks = hooks;
12
- if (node.hooks) {
13
- nextHooks = mergeHooks(nextHooks, node.hooks);
14
- }
15
- if (nodeIsType(node, 'samples')) {
16
- result.set(node.meta.sourceTransaction, nextHooks);
17
- }
18
- return nextHooks;
19
- });
20
- return result;
21
- }
22
- //# sourceMappingURL=load-hooks-from-samples.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load-hooks-from-samples.js","sourceRoot":"","sources":["../../src/hooks/load-hooks-from-samples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAEL,UAAU,GAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,MAAM,UAAU,oBAAoB,CAClC,OAAyB;IAEzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAExC,QAAQ,CACN,OAAO,EACP;QACE,iBAAiB,EAAE,EAAE;QACrB,SAAS,EAAE,EAAE;QACb,iBAAiB,EAAE,EAAE;KACtB,EACD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACd,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare const tsConfig: {
2
- compilerOptions: {
3
- baseUrl: string;
4
- paths: {
5
- '@thymian/hooks': string[];
6
- };
7
- };
8
- include: string[];
9
- };
10
- //# sourceMappingURL=ts-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-config.d.ts","sourceRoot":"","sources":["../../src/hooks/ts-config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAC"}
@@ -1,10 +0,0 @@
1
- export const tsConfig = {
2
- compilerOptions: {
3
- baseUrl: '.',
4
- paths: {
5
- '@thymian/hooks': ['./types.d.ts'],
6
- },
7
- },
8
- include: ['./**/*.ts'],
9
- };
10
- //# sourceMappingURL=ts-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-config.js","sourceRoot":"","sources":["../../src/hooks/ts-config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,eAAe,EAAE;QACf,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE;YACL,gBAAgB,EAAE,CAAC,cAAc,CAAC;SACnC;KACF;IACD,OAAO,EAAE,CAAC,WAAW,CAAC;CACvB,CAAC"}
@@ -1,20 +0,0 @@
1
- export type InlineValue = unknown;
2
- export type FileValue = {
3
- $file: string;
4
- $encoding?: string;
5
- };
6
- export type Value = InlineValue | FileValue;
7
- export type FileRequestSample = {
8
- origin: string;
9
- path: string;
10
- method: string;
11
- authorize: boolean;
12
- bodyEncoding?: string;
13
- headers: Record<string, Value>;
14
- cookies: Record<string, Value>;
15
- pathParameters: Record<string, Value>;
16
- query: Record<string, Value>;
17
- body?: Value;
18
- };
19
- export declare function isFileValue(value: Value): value is FileValue;
20
- //# sourceMappingURL=file-request-sample.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-request-sample.d.ts","sourceRoot":"","sources":["../../src/samples-structure/file-request-sample.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAG5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,SAAS,CAE5D"}
@@ -1,5 +0,0 @@
1
- import { isRecord } from '@thymian/core';
2
- export function isFileValue(value) {
3
- return isRecord(value) && typeof value['$file'] === 'string';
4
- }
5
- //# sourceMappingURL=file-request-sample.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-request-sample.js","sourceRoot":"","sources":["../../src/samples-structure/file-request-sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyBzC,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/D,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type SamplesStructure } from './samples-tree-structure.js';
2
- export declare function getPathTransactionId(id: string, path: string, samples: SamplesStructure): string | undefined;
3
- //# sourceMappingURL=get-path-transaction-id.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-path-transaction-id.d.ts","sourceRoot":"","sources":["../../src/samples-structure/get-path-transaction-id.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAIrC,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,MAAM,GAAG,SAAS,CAuBpB"}
@@ -1,22 +0,0 @@
1
- import { join } from 'node:path';
2
- import { isValidNodeType, nodeIsType, } from './samples-tree-structure.js';
3
- import { traverse } from './traverse.js';
4
- import { getFolderNameFromNode } from './write-samples-to-dir.js';
5
- export function getPathTransactionId(id, path, samples) {
6
- let finalPath = path;
7
- traverse(samples, path, (node, currentPath, prev) => {
8
- if (!isValidNodeType(node.type)) {
9
- throw new Error(`Invalid node type: ${node.type}`);
10
- }
11
- const folderName = getFolderNameFromNode(node);
12
- const newName = join(currentPath, folderName);
13
- if (nodeIsType(node, 'requests') &&
14
- nodeIsType(prev, 'samples') &&
15
- prev.meta.sourceTransaction === id) {
16
- finalPath = newName;
17
- }
18
- return newName;
19
- });
20
- return finalPath === path ? undefined : finalPath;
21
- }
22
- //# sourceMappingURL=get-path-transaction-id.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-path-transaction-id.js","sourceRoot":"","sources":["../../src/samples-structure/get-path-transaction-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,UAAU,GAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,UAAU,oBAAoB,CAClC,EAAU,EACV,IAAY,EACZ,OAAyB;IAEzB,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAClD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAE9C,IACE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;YAC5B,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,iBAAiB,KAAK,EAAE,EAClC,CAAC;YACD,SAAS,GAAG,OAAO,CAAC;QACtB,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
@@ -1,5 +0,0 @@
1
- import { type Hooks, type Node, type SamplesStructure } from './samples-tree-structure.js';
2
- export declare function mergeHooks(a: Hooks | undefined, b: Hooks | undefined): Hooks;
3
- export declare function mergeNodes(a: Node, b: Node): Node;
4
- export declare function mergeTrees(a: SamplesStructure, b: SamplesStructure): SamplesStructure;
5
- //# sourceMappingURL=merge-tree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-tree.d.ts","sourceRoot":"","sources":["../../src/samples-structure/merge-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EAGT,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,CAoB5E;AAuDD,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAiCjD;AAED,wBAAgB,UAAU,CACxB,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GAClB,gBAAgB,CAqBlB"}
@@ -1,118 +0,0 @@
1
- import { ThymianBaseError } from '@thymian/core';
2
- import { nodeIsType, } from './samples-tree-structure.js';
3
- export function mergeHooks(a, b) {
4
- if (!a && !b) {
5
- return {
6
- afterEachResponse: [],
7
- beforeEachRequest: [],
8
- authorize: [],
9
- };
10
- }
11
- return {
12
- beforeEachRequest: [
13
- ...(a?.beforeEachRequest || []),
14
- ...(b?.beforeEachRequest || []),
15
- ],
16
- afterEachResponse: [
17
- ...(a?.afterEachResponse || []),
18
- ...(b?.afterEachResponse || []),
19
- ],
20
- authorize: [...(a?.authorize || []), ...(b?.authorize || [])],
21
- };
22
- }
23
- function getNodeKey(node) {
24
- switch (node.type) {
25
- case 'samples':
26
- return node.type + node.meta.sourceTransaction;
27
- case 'requests':
28
- return node.type;
29
- case 'root':
30
- return node.meta.version;
31
- case 'source':
32
- case 'statusCode':
33
- case 'path':
34
- case 'method':
35
- case 'host':
36
- case 'port':
37
- case 'pathParameter':
38
- case 'requestMediaType':
39
- case 'responseMediaType':
40
- return node.type + node.value;
41
- }
42
- }
43
- function mergeChildLists(as, bs) {
44
- const map = new Map();
45
- for (const node of as) {
46
- map.set(getNodeKey(node), node);
47
- }
48
- for (const nodeB of bs) {
49
- const key = getNodeKey(nodeB);
50
- const nodeA = map.get(key);
51
- if (nodeA) {
52
- map.set(key, mergeNodes(nodeA, nodeB));
53
- }
54
- else {
55
- map.set(key, nodeB);
56
- }
57
- }
58
- return Array.from(map.values());
59
- }
60
- function mergeRequestNodes(a, b) {
61
- return {
62
- type: 'requests',
63
- meta: { ...a.meta, ...b.meta },
64
- hooks: mergeHooks(a.hooks, b.hooks),
65
- // just combine the lists of samples
66
- value: [...(a.value ?? []), ...(b.value ?? [])],
67
- children: [],
68
- };
69
- }
70
- export function mergeNodes(a, b) {
71
- if (a.type !== b.type) {
72
- throw new ThymianBaseError(`Cannot merge nodes of different types: ${a.type} vs ${b.type}`, {
73
- name: 'NodeTypeMismatchError',
74
- ref: 'https://thymian.dev/references/errors/node-type-mismatch-error/',
75
- });
76
- }
77
- if (nodeIsType(a, 'requests') && nodeIsType(b, 'requests')) {
78
- return mergeRequestNodes(a, b);
79
- }
80
- else if (!nodeIsType(a, 'requests') && !nodeIsType(b, 'requests')) {
81
- const node = {
82
- type: a.type,
83
- value: a.value,
84
- hooks: mergeHooks(a.hooks, b.hooks),
85
- children: mergeChildLists(a.children, b.children),
86
- meta: { ...(a.meta ?? {}), ...(b.meta ?? {}) },
87
- };
88
- if (a.meta || b.meta) {
89
- node.meta = { ...(a.meta ?? {}), ...(b.meta ?? {}) };
90
- }
91
- // this is VERY ugly, but it's currently the price for the type safe tree structure. We should probably refactor this later.
92
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
93
- // @ts-expect-error
94
- return node;
95
- }
96
- else {
97
- throw new Error('This should never happen: ' + a + ' ' + b);
98
- }
99
- }
100
- export function mergeTrees(a, b) {
101
- if (a.meta.version !== b.meta.version) {
102
- throw new ThymianBaseError(`Cannot merge SamplesTrees with different versions: ${a.meta.version} vs ${b.meta.version}`, {
103
- name: 'SamplesVersionMismatchError',
104
- ref: 'https://thymian.dev/references/errors/samples-version-mismatch-error/',
105
- });
106
- }
107
- return {
108
- type: 'root',
109
- meta: {
110
- version: a.meta.version,
111
- timestamp: Math.max(a.meta.timestamp, b.meta.timestamp),
112
- },
113
- hooks: mergeHooks(a.hooks, b.hooks),
114
- // this cast is ugly, but it's the price for the type safe tree structure
115
- children: mergeChildLists(a.children, b.children),
116
- };
117
- }
118
- //# sourceMappingURL=merge-tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-tree.js","sourceRoot":"","sources":["../../src/samples-structure/merge-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAGL,UAAU,GAIX,MAAM,6BAA6B,CAAC;AAErC,MAAM,UAAU,UAAU,CAAC,CAAoB,EAAE,CAAoB;IACnE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACb,OAAO;YACL,iBAAiB,EAAE,EAAE;YACrB,iBAAiB,EAAE,EAAE;YACrB,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,iBAAiB,EAAE;YACjB,GAAG,CAAC,CAAC,EAAE,iBAAiB,IAAI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CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAC3F;YACE,IAAI,EAAE,6BAA6B;YACnC,GAAG,EAAE,uEAAuE;SAC7E,CACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO;YACvB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;SACxD;QACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;QACnC,yEAAyE;QACzE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAiB;KAClE,CAAC;AACJ,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { ContentSource, HttpRequestSample } from '../http-request-sample.js';
2
- import { type Value } from './file-request-sample.js';
3
- import type { Hooks, Node, NodeTypes, SamplesNode, SamplesStructure } from './samples-tree-structure.js';
4
- import type { PathToNodeType } from './structure-meta-on-disc.js';
5
- export declare function tryImport<T>(path: string): Promise<T>;
6
- export declare function extractParameterValues(parameters: Record<string, Value>, basePath: string): Promise<Record<string, ContentSource>>;
7
- export declare function extractSample(path: string): Promise<HttpRequestSample>;
8
- export declare function extractSamplesNode<T extends Exclude<Node, SamplesNode | SamplesStructure>['type']>(dir: string, type: T): Promise<NodeTypes[T]>;
9
- export declare function extractHooksFromDir(dir: string): Promise<Hooks>;
10
- export declare function dirNameToValue(dirName: string, type: Exclude<Node, SamplesNode | SamplesStructure>['type']): string;
11
- export declare function extractNodes(baseDir: string, relativeDir: string, currentDirName: string, meta: PathToNodeType): Promise<Node>;
12
- export declare function readSamplesFromDir(dir: string): Promise<SamplesStructure>;
13
- //# sourceMappingURL=read-samples-from-dir.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-samples-from-dir.d.ts","sourceRoot":"","sources":["../../src/samples-structure/read-samples-from-dir.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,KAAK,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EAET,WAAW,EAEX,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,6BAA6B,CAAC;AAIrC,wBAAsB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAc3D;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAuBxC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqD5E;AAED,wBAAsB,kBAAkB,CACtC,CAAC,SAAS,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAAC,MAAM,CAAC,EAC/D,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAoC7C;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAiCrE;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAAC,MAAM,CAAC,GAC1D,MAAM,CASR;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,CAAC,CAwB3B"}
@@ -1,205 +0,0 @@
1
- import { readdir, readFile } from 'node:fs/promises';
2
- import { type } from 'node:os';
3
- import { basename, dirname, join } from 'node:path';
4
- import { ThymianBaseError } from '@thymian/core';
5
- import { createJiti } from 'jiti';
6
- import { AFTER_EACH_HOOK, AUTHORIZE_HOOK, BEFORE_EACH_HOOK, SAMPLE_FILE, } from '../constants.js';
7
- import { checkForSafePath } from '../utils.js';
8
- import { isFileValue, } from './file-request-sample.js';
9
- const jiti = createJiti(import.meta.url);
10
- export async function tryImport(path) {
11
- const module = await jiti.import(path, { default: true });
12
- if (module === null || typeof module !== 'function') {
13
- throw new ThymianBaseError(`Could not import hook from "${path}".`, {
14
- name: 'HookImportError',
15
- ref: 'https://thymian.dev/references/errors/hook-import-error/',
16
- suggestions: [
17
- 'Check that the hook file exists and the hook function is exported as default.',
18
- ],
19
- });
20
- }
21
- return module;
22
- }
23
- export async function extractParameterValues(parameters, basePath) {
24
- const result = {};
25
- for (const [key, value] of Object.entries(parameters)) {
26
- if (isFileValue(value)) {
27
- const fullPath = join(basePath, value.$file);
28
- checkForSafePath(fullPath, basePath);
29
- result[key] = {
30
- $content: await readFile(fullPath, (value.$encoding ?? 'utf-8')),
31
- };
32
- }
33
- else {
34
- result[key] = {
35
- $content: value,
36
- };
37
- }
38
- }
39
- return result;
40
- }
41
- export async function extractSample(path) {
42
- const sampleFile = await readFile(path, 'utf-8');
43
- const requestsDir = dirname(path);
44
- let fileSample;
45
- try {
46
- fileSample = JSON.parse(sampleFile);
47
- }
48
- catch (err) {
49
- throw new ThymianBaseError(`Could not parse JSON sample file "${path}".`, {
50
- name: 'InvalidSampleJSONError',
51
- ref: 'https://thymian.dev/references/errors/invalid-sample-json-error/',
52
- suggestions: ['Check that the sample file is valid JSON.'],
53
- cause: err,
54
- });
55
- }
56
- const sample = {
57
- authorize: fileSample.authorize,
58
- cookies: await extractParameterValues(fileSample.cookies, requestsDir),
59
- headers: await extractParameterValues(fileSample.headers, requestsDir),
60
- method: fileSample.method,
61
- origin: fileSample.origin,
62
- path: fileSample.path,
63
- pathParameters: await extractParameterValues(fileSample.pathParameters, requestsDir),
64
- query: await extractParameterValues(fileSample.query, requestsDir),
65
- bodyEncoding: fileSample.bodyEncoding,
66
- };
67
- if (fileSample.body) {
68
- if (isFileValue(fileSample.body)) {
69
- const bodyPath = join(requestsDir, fileSample.body.$file);
70
- checkForSafePath(bodyPath, requestsDir);
71
- sample.body = {
72
- $content: await readFile(bodyPath, (fileSample.body.$encoding ??
73
- fileSample.bodyEncoding ??
74
- 'utf-8')),
75
- };
76
- }
77
- else {
78
- sample.body = {
79
- $content: fileSample.body,
80
- };
81
- }
82
- }
83
- return sample;
84
- }
85
- export async function extractSamplesNode(dir, type) {
86
- const metaPath = join(dir, 'meta.json');
87
- const meta = JSON.parse(await readFile(metaPath, 'utf-8'));
88
- const request = {
89
- children: [],
90
- type: 'requests',
91
- value: [],
92
- };
93
- for (const dirent of await readdir(join(dir, 'requests'), {
94
- recursive: false,
95
- withFileTypes: true,
96
- })) {
97
- if (dirent.isFile() && SAMPLE_FILE.test(dirent.name)) {
98
- request.value.push(await extractSample(join(dir, 'requests', dirent.name)));
99
- }
100
- }
101
- const samplesNode = {
102
- meta,
103
- type: 'samples',
104
- hooks: await extractHooksFromDir(dir),
105
- children: [request],
106
- };
107
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
108
- // @ts-expect-error
109
- return {
110
- type,
111
- children: [samplesNode],
112
- value: dirNameToValue(basename(dir), type),
113
- };
114
- }
115
- export async function extractHooksFromDir(dir) {
116
- const hooks = {
117
- afterEachResponse: [],
118
- authorize: [],
119
- beforeEachRequest: [],
120
- };
121
- for (const dirent of await readdir(dir, {
122
- recursive: false,
123
- withFileTypes: true,
124
- })) {
125
- if (dirent.isFile()) {
126
- const filePath = join(dir, dirent.name);
127
- if (BEFORE_EACH_HOOK.test(dirent.name)) {
128
- hooks.beforeEachRequest.push(await tryImport(filePath));
129
- }
130
- if (AFTER_EACH_HOOK.test(dirent.name)) {
131
- hooks.afterEachResponse.push(await tryImport(filePath));
132
- }
133
- if (AUTHORIZE_HOOK.test(dirent.name)) {
134
- hooks.authorize.push(await tryImport(filePath));
135
- }
136
- }
137
- }
138
- return hooks;
139
- }
140
- export function dirNameToValue(dirName, type) {
141
- switch (type) {
142
- case 'pathParameter':
143
- return `${dirName.substring(1, dirName.length - 1)}`;
144
- case 'method':
145
- return dirName.replace('@', '').toLowerCase();
146
- default:
147
- return dirName;
148
- }
149
- }
150
- export async function extractNodes(baseDir, relativeDir, currentDirName, meta) {
151
- const { type, containsSamples } = meta[relativeDir] ?? {};
152
- if (typeof type === 'undefined') {
153
- throw new Error(`Unknown type: ${relativeDir}`);
154
- }
155
- if (type === 'root' || type === 'samples') {
156
- throw new Error('Cannot extract root node from samples directory.');
157
- }
158
- const fullPath = join(baseDir, relativeDir);
159
- if (containsSamples) {
160
- return await extractSamplesNode(fullPath, type);
161
- }
162
- else if (type === 'requests') {
163
- /**
164
- * is extracted within the extractSamplesNode function
165
- */
166
- throw new Error('Should not happen');
167
- }
168
- else {
169
- const fullPath = join(baseDir, relativeDir);
170
- const node = {
171
- value: dirNameToValue(currentDirName, type),
172
- children: [],
173
- type,
174
- hooks: await extractHooksFromDir(fullPath),
175
- };
176
- for (const dirent of await readdir(fullPath, {
177
- recursive: false,
178
- withFileTypes: true,
179
- })) {
180
- if (dirent.isDirectory()) {
181
- node.children.push(await extractNodes(baseDir, join(relativeDir, dirent.name), dirent.name, meta));
182
- }
183
- }
184
- return node;
185
- }
186
- }
187
- export async function readSamplesFromDir(dir) {
188
- const meta = JSON.parse(await readFile(join(dir, 'meta.json'), 'utf-8'));
189
- const samples = {
190
- children: [],
191
- meta: meta.version,
192
- type: 'root',
193
- hooks: await extractHooksFromDir(dir),
194
- };
195
- for (const dirent of await readdir(dir, {
196
- recursive: false,
197
- withFileTypes: true,
198
- })) {
199
- if (dirent.isDirectory()) {
200
- samples.children.push(await extractNodes(dir, dirent.name, dirent.name, meta.types));
201
- }
202
- }
203
- return samples;
204
- }
205
- //# sourceMappingURL=read-samples-from-dir.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-samples-from-dir.js","sourceRoot":"","sources":["../../src/samples-structure/read-samples-from-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAEL,WAAW,GAEZ,MAAM,0BAA0B,CAAC;AAelC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,IAAY;IAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAI,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,gBAAgB,CAAC,+BAA+B,IAAI,IAAI,EAAE;YAClE,IAAI,EAAE,iBAAiB;YAC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,EACP,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,EAC9B,MAAM,CAAC,IAAI,EACX,IAAI,CACL,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAW;IAEX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CACrB,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,CACzB,CAAC;IAEzB,MAAM,OAAO,GAAqB;QAChC,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,IAAI,CAAC,OAAO;QAClB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC;KACtC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE;QACtC,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC,EAAE,CAAC;QACH,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;YACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CACnB,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,5 +0,0 @@
1
- import { type ThymianHttpTransaction } from '@thymian/core';
2
- import type { HttpRequestSample } from '../http-request-sample.js';
3
- import type { SamplesStructure } from './samples-tree-structure.js';
4
- export declare function samplesTreeFromThymianHttpTransaction(sample: HttpRequestSample, transaction: ThymianHttpTransaction, version: string): SamplesStructure;
5
- //# sourceMappingURL=samples-from-transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"samples-from-transactions.d.ts","sourceRoot":"","sources":["../../src/samples-structure/samples-from-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EASV,gBAAgB,EAGjB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,MAAM,GACd,gBAAgB,CA+HlB"}
@@ -1,120 +0,0 @@
1
- import { URL } from 'node:url';
2
- import { thymianRequestToOrigin, } from '@thymian/core';
3
- import { sanitize } from '../utils.js';
4
- export function samplesTreeFromThymianHttpTransaction(sample, transaction, version) {
5
- const tree = {
6
- type: 'root',
7
- children: [],
8
- meta: {
9
- version,
10
- timestamp: Date.now(),
11
- },
12
- };
13
- const url = new URL(thymianRequestToOrigin(transaction.thymianReq));
14
- const host = sanitize(url.hostname);
15
- const sourceNode = {
16
- children: [],
17
- type: 'source',
18
- value: transaction.transaction.sourceName,
19
- };
20
- tree.children.push(sourceNode);
21
- const hostNode = {
22
- type: 'host',
23
- value: host,
24
- children: [],
25
- };
26
- sourceNode.children.push(hostNode);
27
- const portNode = {
28
- type: 'port',
29
- value: url.port,
30
- children: [],
31
- };
32
- hostNode.children.push(portNode);
33
- const nextNode = transaction.thymianReq.path
34
- .split('/')
35
- .filter((s) => s.length > 0)
36
- .reduce((prev, path) => {
37
- if (/^\{.*}$/.test(path)) {
38
- const pathParameterNode = {
39
- type: 'pathParameter',
40
- value: path.substring(1, path.length - 1),
41
- children: [],
42
- };
43
- prev.children.push(pathParameterNode);
44
- return pathParameterNode;
45
- }
46
- else {
47
- const pathNode = {
48
- type: 'path',
49
- value: path,
50
- children: [],
51
- };
52
- prev.children.push(pathNode);
53
- return pathNode;
54
- }
55
- }, portNode);
56
- const methodNode = {
57
- type: 'method',
58
- value: transaction.thymianReq.method.toLowerCase(),
59
- children: [],
60
- };
61
- nextNode.children.push(methodNode);
62
- let maybeReqMediaTypeNode;
63
- if (transaction.thymianReq.mediaType) {
64
- maybeReqMediaTypeNode = {
65
- type: 'requestMediaType',
66
- value: transaction.thymianReq.mediaType,
67
- children: [],
68
- };
69
- methodNode.children.push(maybeReqMediaTypeNode);
70
- }
71
- const statusCodeNode = {
72
- type: 'statusCode',
73
- value: transaction.thymianRes.statusCode.toString(),
74
- children: [],
75
- };
76
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
77
- maybeReqMediaTypeNode
78
- ? maybeReqMediaTypeNode.children.push(statusCodeNode)
79
- : methodNode.children.push(statusCodeNode);
80
- let maybeResMediaTypeNode;
81
- if (transaction.thymianRes.mediaType) {
82
- maybeResMediaTypeNode = {
83
- type: 'responseMediaType',
84
- value: transaction.thymianRes.mediaType,
85
- children: [],
86
- };
87
- statusCodeNode.children.push(maybeResMediaTypeNode);
88
- }
89
- const requestsNode = {
90
- children: [],
91
- type: 'requests',
92
- value: [sample],
93
- };
94
- if (maybeResMediaTypeNode) {
95
- maybeResMediaTypeNode.children.push({
96
- type: 'samples',
97
- meta: {
98
- sourceTransaction: transaction.transactionId,
99
- samplingStrategy: {
100
- type: 'random',
101
- },
102
- },
103
- children: [requestsNode],
104
- });
105
- }
106
- else {
107
- statusCodeNode.children.push({
108
- type: 'samples',
109
- meta: {
110
- sourceTransaction: transaction.transactionId,
111
- samplingStrategy: {
112
- type: 'random',
113
- },
114
- },
115
- children: [requestsNode],
116
- });
117
- }
118
- return tree;
119
- }
120
- //# sourceMappingURL=samples-from-transactions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"samples-from-transactions.js","sourceRoot":"","sources":["../../src/samples-structure/samples-from-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAEL,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,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