@thymian/plugin-sampler 0.0.0-PLACEHOLDER

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 (170) hide show
  1. package/README.md +59 -0
  2. package/dist/cli/commands/sampler/check.d.ts +16 -0
  3. package/dist/cli/commands/sampler/check.d.ts.map +1 -0
  4. package/dist/cli/commands/sampler/check.js +135 -0
  5. package/dist/cli/commands/sampler/check.js.map +1 -0
  6. package/dist/cli/commands/sampler/generate/hook.d.ts +9 -0
  7. package/dist/cli/commands/sampler/generate/hook.d.ts.map +1 -0
  8. package/dist/cli/commands/sampler/generate/hook.js +18 -0
  9. package/dist/cli/commands/sampler/generate/hook.js.map +1 -0
  10. package/dist/cli/commands/sampler/init.d.ts +9 -0
  11. package/dist/cli/commands/sampler/init.d.ts.map +1 -0
  12. package/dist/cli/commands/sampler/init.js +55 -0
  13. package/dist/cli/commands/sampler/init.js.map +1 -0
  14. package/dist/cli/create-context.d.ts +3 -0
  15. package/dist/cli/create-context.d.ts.map +1 -0
  16. package/dist/cli/create-context.js +21 -0
  17. package/dist/cli/create-context.js.map +1 -0
  18. package/dist/cli/generate-hook.d.ts +4 -0
  19. package/dist/cli/generate-hook.d.ts.map +1 -0
  20. package/dist/cli/generate-hook.js +92 -0
  21. package/dist/cli/generate-hook.js.map +1 -0
  22. package/dist/cli/templates.d.ts +4 -0
  23. package/dist/cli/templates.d.ts.map +1 -0
  24. package/dist/cli/templates.js +28 -0
  25. package/dist/cli/templates.js.map +1 -0
  26. package/dist/constants.d.ts +5 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/constants.js +5 -0
  29. package/dist/constants.js.map +1 -0
  30. package/dist/generation/content-source-generator.d.ts +10 -0
  31. package/dist/generation/content-source-generator.d.ts.map +1 -0
  32. package/dist/generation/content-source-generator.js +15 -0
  33. package/dist/generation/content-source-generator.js.map +1 -0
  34. package/dist/generation/content-type-strategies/content-type-strategy.d.ts +7 -0
  35. package/dist/generation/content-type-strategies/content-type-strategy.d.ts.map +1 -0
  36. package/dist/generation/content-type-strategies/content-type-strategy.js +2 -0
  37. package/dist/generation/content-type-strategies/content-type-strategy.js.map +1 -0
  38. package/dist/generation/content-type-strategies/error.content-type-strategy.d.ts +7 -0
  39. package/dist/generation/content-type-strategies/error.content-type-strategy.d.ts.map +1 -0
  40. package/dist/generation/content-type-strategies/error.content-type-strategy.js +13 -0
  41. package/dist/generation/content-type-strategies/error.content-type-strategy.js.map +1 -0
  42. package/dist/generation/content-type-strategies/hook.content-type-strategy.d.ts +10 -0
  43. package/dist/generation/content-type-strategies/hook.content-type-strategy.d.ts.map +1 -0
  44. package/dist/generation/content-type-strategies/hook.content-type-strategy.js +27 -0
  45. package/dist/generation/content-type-strategies/hook.content-type-strategy.js.map +1 -0
  46. package/dist/generation/content-type-strategies/image.content-type-strategy.d.ts +15 -0
  47. package/dist/generation/content-type-strategies/image.content-type-strategy.d.ts.map +1 -0
  48. package/dist/generation/content-type-strategies/image.content-type-strategy.js +40 -0
  49. package/dist/generation/content-type-strategies/image.content-type-strategy.js.map +1 -0
  50. package/dist/generation/content-type-strategies/json.content-type-strategy.d.ts +8 -0
  51. package/dist/generation/content-type-strategies/json.content-type-strategy.d.ts.map +1 -0
  52. package/dist/generation/content-type-strategies/json.content-type-strategy.js +12 -0
  53. package/dist/generation/content-type-strategies/json.content-type-strategy.js.map +1 -0
  54. package/dist/generation/content-type-strategies/text.content-type-strategy.d.ts +8 -0
  55. package/dist/generation/content-type-strategies/text.content-type-strategy.d.ts.map +1 -0
  56. package/dist/generation/content-type-strategies/text.content-type-strategy.js +13 -0
  57. package/dist/generation/content-type-strategies/text.content-type-strategy.js.map +1 -0
  58. package/dist/generation/content-type-strategies/xml.content-type-strategy.d.ts +8 -0
  59. package/dist/generation/content-type-strategies/xml.content-type-strategy.d.ts.map +1 -0
  60. package/dist/generation/content-type-strategies/xml.content-type-strategy.js +14 -0
  61. package/dist/generation/content-type-strategies/xml.content-type-strategy.js.map +1 -0
  62. package/dist/generation/generate-samples-for-thymian-format.d.ts +4 -0
  63. package/dist/generation/generate-samples-for-thymian-format.d.ts.map +1 -0
  64. package/dist/generation/generate-samples-for-thymian-format.js +18 -0
  65. package/dist/generation/generate-samples-for-thymian-format.js.map +1 -0
  66. package/dist/generation/generate-samples.d.ts +4 -0
  67. package/dist/generation/generate-samples.d.ts.map +1 -0
  68. package/dist/generation/generate-samples.js +26 -0
  69. package/dist/generation/generate-samples.js.map +1 -0
  70. package/dist/generation/request-generators/default-request-generator.d.ts +22 -0
  71. package/dist/generation/request-generators/default-request-generator.d.ts.map +1 -0
  72. package/dist/generation/request-generators/default-request-generator.js +80 -0
  73. package/dist/generation/request-generators/default-request-generator.js.map +1 -0
  74. package/dist/generation/request-generators/range-request-generator.d.ts +8 -0
  75. package/dist/generation/request-generators/range-request-generator.d.ts.map +1 -0
  76. package/dist/generation/request-generators/range-request-generator.js +22 -0
  77. package/dist/generation/request-generators/range-request-generator.js.map +1 -0
  78. package/dist/generation/request-generators/unauthorized-request-generator.d.ts +6 -0
  79. package/dist/generation/request-generators/unauthorized-request-generator.d.ts.map +1 -0
  80. package/dist/generation/request-generators/unauthorized-request-generator.js +10 -0
  81. package/dist/generation/request-generators/unauthorized-request-generator.js.map +1 -0
  82. package/dist/hooks/create-hook-utils.d.ts +8 -0
  83. package/dist/hooks/create-hook-utils.d.ts.map +1 -0
  84. package/dist/hooks/create-hook-utils.js +137 -0
  85. package/dist/hooks/create-hook-utils.js.map +1 -0
  86. package/dist/hooks/generate-request-types.d.ts +30 -0
  87. package/dist/hooks/generate-request-types.d.ts.map +1 -0
  88. package/dist/hooks/generate-request-types.js +424 -0
  89. package/dist/hooks/generate-request-types.js.map +1 -0
  90. package/dist/hooks/hook-errors.d.ts +5 -0
  91. package/dist/hooks/hook-errors.d.ts.map +1 -0
  92. package/dist/hooks/hook-errors.js +5 -0
  93. package/dist/hooks/hook-errors.js.map +1 -0
  94. package/dist/hooks/hook-runner.d.ts +18 -0
  95. package/dist/hooks/hook-runner.d.ts.map +1 -0
  96. package/dist/hooks/hook-runner.js +172 -0
  97. package/dist/hooks/hook-runner.js.map +1 -0
  98. package/dist/hooks/hook-types.d.ts +7 -0
  99. package/dist/hooks/hook-types.d.ts.map +1 -0
  100. package/dist/hooks/hook-types.js +2 -0
  101. package/dist/hooks/hook-types.js.map +1 -0
  102. package/dist/hooks/hook-utils.d.ts +36 -0
  103. package/dist/hooks/hook-utils.d.ts.map +1 -0
  104. package/dist/hooks/hook-utils.js +2 -0
  105. package/dist/hooks/hook-utils.js.map +1 -0
  106. package/dist/hooks/load-hooks-from-samples.d.ts +3 -0
  107. package/dist/hooks/load-hooks-from-samples.d.ts.map +1 -0
  108. package/dist/hooks/load-hooks-from-samples.js +22 -0
  109. package/dist/hooks/load-hooks-from-samples.js.map +1 -0
  110. package/dist/hooks/ts-config.d.ts +10 -0
  111. package/dist/hooks/ts-config.d.ts.map +1 -0
  112. package/dist/hooks/ts-config.js +10 -0
  113. package/dist/hooks/ts-config.js.map +1 -0
  114. package/dist/http-request-sample.d.ts +24 -0
  115. package/dist/http-request-sample.d.ts.map +1 -0
  116. package/dist/http-request-sample.js +11 -0
  117. package/dist/http-request-sample.js.map +1 -0
  118. package/dist/index.d.ts +41 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +145 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/request-sample-to-request-template.d.ts +6 -0
  123. package/dist/request-sample-to-request-template.d.ts.map +1 -0
  124. package/dist/request-sample-to-request-template.js +35 -0
  125. package/dist/request-sample-to-request-template.js.map +1 -0
  126. package/dist/request-sampler.d.ts +15 -0
  127. package/dist/request-sampler.d.ts.map +1 -0
  128. package/dist/request-sampler.js +82 -0
  129. package/dist/request-sampler.js.map +1 -0
  130. package/dist/samples-structure/file-request-sample.d.ts +20 -0
  131. package/dist/samples-structure/file-request-sample.d.ts.map +1 -0
  132. package/dist/samples-structure/file-request-sample.js +5 -0
  133. package/dist/samples-structure/file-request-sample.js.map +1 -0
  134. package/dist/samples-structure/get-path-transaction-id.d.ts +3 -0
  135. package/dist/samples-structure/get-path-transaction-id.d.ts.map +1 -0
  136. package/dist/samples-structure/get-path-transaction-id.js +22 -0
  137. package/dist/samples-structure/get-path-transaction-id.js.map +1 -0
  138. package/dist/samples-structure/merge-tree.d.ts +5 -0
  139. package/dist/samples-structure/merge-tree.d.ts.map +1 -0
  140. package/dist/samples-structure/merge-tree.js +118 -0
  141. package/dist/samples-structure/merge-tree.js.map +1 -0
  142. package/dist/samples-structure/read-samples-from-dir.d.ts +13 -0
  143. package/dist/samples-structure/read-samples-from-dir.d.ts.map +1 -0
  144. package/dist/samples-structure/read-samples-from-dir.js +204 -0
  145. package/dist/samples-structure/read-samples-from-dir.js.map +1 -0
  146. package/dist/samples-structure/samples-from-transactions.d.ts +5 -0
  147. package/dist/samples-structure/samples-from-transactions.d.ts.map +1 -0
  148. package/dist/samples-structure/samples-from-transactions.js +120 -0
  149. package/dist/samples-structure/samples-from-transactions.js.map +1 -0
  150. package/dist/samples-structure/samples-tree-structure.d.ts +106 -0
  151. package/dist/samples-structure/samples-tree-structure.d.ts.map +1 -0
  152. package/dist/samples-structure/samples-tree-structure.js +26 -0
  153. package/dist/samples-structure/samples-tree-structure.js.map +1 -0
  154. package/dist/samples-structure/structure-meta-on-disc.d.ts +11 -0
  155. package/dist/samples-structure/structure-meta-on-disc.d.ts.map +1 -0
  156. package/dist/samples-structure/structure-meta-on-disc.js +2 -0
  157. package/dist/samples-structure/structure-meta-on-disc.js.map +1 -0
  158. package/dist/samples-structure/traverse.d.ts +4 -0
  159. package/dist/samples-structure/traverse.d.ts.map +1 -0
  160. package/dist/samples-structure/traverse.js +13 -0
  161. package/dist/samples-structure/traverse.js.map +1 -0
  162. package/dist/samples-structure/write-samples-to-dir.d.ts +25 -0
  163. package/dist/samples-structure/write-samples-to-dir.d.ts.map +1 -0
  164. package/dist/samples-structure/write-samples-to-dir.js +173 -0
  165. package/dist/samples-structure/write-samples-to-dir.js.map +1 -0
  166. package/dist/utils.d.ts +4 -0
  167. package/dist/utils.d.ts.map +1 -0
  168. package/dist/utils.js +26 -0
  169. package/dist/utils.js.map +1 -0
  170. package/package.json +70 -0
@@ -0,0 +1,13 @@
1
+ import { ThymianBaseError } from '@thymian/core';
2
+ export class ErrorContentTypeStrategy {
3
+ matches() {
4
+ return false;
5
+ }
6
+ generate(schema, contentType) {
7
+ throw new ThymianBaseError(`Cannot generate content for content type "${contentType}".`, {
8
+ name: 'UnsupportedContentTypeError',
9
+ ref: 'https://thymian.dev/references/errors/unsupported-content-type-error/',
10
+ });
11
+ }
12
+ }
13
+ //# sourceMappingURL=error.content-type-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/error.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AAIrE,MAAM,OAAO,wBAAwB;IACnC,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,MAAqB,EAAE,WAAmB;QACjD,MAAM,IAAI,gBAAgB,CACxB,6CAA6C,WAAW,IAAI,EAC5D;YACE,IAAI,EAAE,6BAA6B;YACnC,GAAG,EAAE,uEAAuE;SAC7E,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { ThymianEmitter, type ThymianSchema } from '@thymian/core';
2
+ import type { ContentSource } from '../../http-request-sample.js';
3
+ import type { ContentTypeStrategy } from './content-type-strategy.js';
4
+ export declare class HookContentTypeStrategy implements ContentTypeStrategy {
5
+ private readonly emitter;
6
+ constructor(emitter: ThymianEmitter);
7
+ matches(): boolean;
8
+ generate(schema: ThymianSchema, contentType: string): Promise<ContentSource>;
9
+ }
10
+ //# sourceMappingURL=hook.content-type-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/hook.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,qBAAa,uBAAwB,YAAW,mBAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,OAAO,IAAI,OAAO;IAIZ,QAAQ,CACZ,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC;CAyB1B"}
@@ -0,0 +1,27 @@
1
+ import { ThymianBaseError, ThymianEmitter, } from '@thymian/core';
2
+ export class HookContentTypeStrategy {
3
+ emitter;
4
+ constructor(emitter) {
5
+ this.emitter = emitter;
6
+ }
7
+ matches() {
8
+ return false;
9
+ }
10
+ async generate(schema, contentType) {
11
+ const content = await this.emitter.emitAction('sampler.unknown-type', {
12
+ schema,
13
+ contentType,
14
+ }, {
15
+ strategy: 'first',
16
+ strict: false,
17
+ });
18
+ if (!content) {
19
+ throw new ThymianBaseError(`Cannot sample data for content type ${contentType}.`, {
20
+ name: 'UnsupportedContentTypeError',
21
+ ref: 'https://thymian.dev/references/errors/unsupported-content-type-error/',
22
+ });
23
+ }
24
+ return content;
25
+ }
26
+ }
27
+ //# sourceMappingURL=hook.content-type-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/hook.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,GAEf,MAAM,eAAe,CAAC;AAKvB,MAAM,OAAO,uBAAuB;IACL;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,MAAqB,EACrB,WAAmB;QAEnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAC3C,sBAAsB,EACtB;YACE,MAAM;YACN,WAAW;SACZ,EACD;YACE,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,KAAK;SACd,CACF,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,gBAAgB,CACxB,uCAAuC,WAAW,GAAG,EACrD;gBACE,IAAI,EAAE,6BAA6B;gBACnC,GAAG,EAAE,uEAAuE;aAC7E,CACF,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { ThymianSchema } from '@thymian/core';
2
+ import type { ContentSource } from '../../http-request-sample.js';
3
+ import type { ContentTypeStrategy } from './content-type-strategy.js';
4
+ export type ImageContentTypeStrategyOptions = {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export declare class ImageContentTypeStrategy implements ContentTypeStrategy {
9
+ private readonly options;
10
+ constructor(options?: Partial<ImageContentTypeStrategyOptions>);
11
+ matches(contentType: string): boolean;
12
+ generate(schema: ThymianSchema, contentType: string): Promise<ContentSource>;
13
+ private randomPixelsBuffer;
14
+ }
15
+ //# sourceMappingURL=image.content-type-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/image.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;AAEtE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,mBAAmB;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;gBAE9C,OAAO,GAAE,OAAO,CAAC,+BAA+B,CAAM;IAQlE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CACZ,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC;IAoBzB,OAAO,CAAC,kBAAkB;CAS3B"}
@@ -0,0 +1,40 @@
1
+ import sharp from 'sharp';
2
+ export class ImageContentTypeStrategy {
3
+ options;
4
+ constructor(options = {}) {
5
+ this.options = {
6
+ width: 256,
7
+ height: 256,
8
+ ...options,
9
+ };
10
+ }
11
+ matches(contentType) {
12
+ // TODO: fill regex https://sharp.pixelplumbing.com/api-output/
13
+ return /^image\/(jpeg|png|jpg)/i.test(contentType);
14
+ }
15
+ async generate(schema, contentType) {
16
+ let content = sharp(this.randomPixelsBuffer(), {
17
+ raw: {
18
+ width: this.options.width,
19
+ height: this.options.height,
20
+ channels: 3,
21
+ },
22
+ });
23
+ content = /^image\/(png)/i.test(contentType)
24
+ ? content.png()
25
+ : content.jpeg();
26
+ return {
27
+ $encoding: 'base64',
28
+ $buffer: await content.toBuffer(),
29
+ $ext: 'png',
30
+ };
31
+ }
32
+ randomPixelsBuffer() {
33
+ const buffer = Buffer.alloc(this.options.height * this.options.width * 3);
34
+ for (let i = 0; i < buffer.length; i++) {
35
+ buffer[i] = Math.floor(Math.random() * 256);
36
+ }
37
+ return buffer;
38
+ }
39
+ }
40
+ //# sourceMappingURL=image.content-type-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/image.content-type-strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAA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,CAAC;QAC9C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { ThymianSchema } from '@thymian/core';
2
+ import type { ContentSource } from '../../http-request-sample.js';
3
+ import type { ContentTypeStrategy } from './content-type-strategy.js';
4
+ export declare class JsonContentTypeStrategy implements ContentTypeStrategy {
5
+ matches(contentType: string): boolean;
6
+ generate(schema: ThymianSchema): Promise<ContentSource>;
7
+ }
8
+ //# sourceMappingURL=json.content-type-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/json.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAK9D"}
@@ -0,0 +1,12 @@
1
+ import { sample } from 'openapi-sampler';
2
+ export class JsonContentTypeStrategy {
3
+ matches(contentType) {
4
+ return /^application\/[^+]*[+]?(json);?.*/.test(contentType);
5
+ }
6
+ async generate(schema) {
7
+ return {
8
+ $content: sample(schema),
9
+ };
10
+ }
11
+ }
12
+ //# sourceMappingURL=json.content-type-strategy.js.map
@@ -0,0 +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,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { ThymianSchema } from '@thymian/core';
2
+ import type { ContentSource } from '../../http-request-sample.js';
3
+ import type { ContentTypeStrategy } from './content-type-strategy.js';
4
+ export declare class PlainTextContentTypeStrategy implements ContentTypeStrategy {
5
+ matches(contentType: string): boolean;
6
+ generate(schema: ThymianSchema): Promise<ContentSource>;
7
+ }
8
+ //# sourceMappingURL=text.content-type-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/text.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAO9D"}
@@ -0,0 +1,13 @@
1
+ export class PlainTextContentTypeStrategy {
2
+ matches(contentType) {
3
+ return /^text\/plain;?.*/.test(contentType);
4
+ }
5
+ async generate(schema) {
6
+ return {
7
+ $encoding: 'utf-8',
8
+ $ext: '.txt',
9
+ $buffer: Buffer.from(schema.examples?.[0]?.toString() || 'plain text'),
10
+ };
11
+ }
12
+ }
13
+ //# sourceMappingURL=text.content-type-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/text.content-type-strategy.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,4BAA4B;IACvC,OAAO,CAAC,WAAmB;QACzB,OAAO,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqB;QAClC,OAAO;YACL,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,YAAY,CAAC;SACvE,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { ThymianSchema } from '@thymian/core';
2
+ import type { ContentSource } from '../../http-request-sample.js';
3
+ import type { ContentTypeStrategy } from './content-type-strategy.js';
4
+ export declare class XmlContentTypeStrategy implements ContentTypeStrategy {
5
+ matches(contentType: string): boolean;
6
+ generate(schema: ThymianSchema): Promise<ContentSource>;
7
+ }
8
+ //# sourceMappingURL=xml.content-type-strategy.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ import { sample } from 'openapi-sampler';
2
+ export class XmlContentTypeStrategy {
3
+ matches(contentType) {
4
+ return /^application\/[^+]*[+]?(xml);?.*/.test(contentType);
5
+ }
6
+ async generate(schema) {
7
+ return {
8
+ $encoding: 'utf-8',
9
+ $ext: 'xml',
10
+ $buffer: Buffer.from(sample(schema, { format: 'xml' })),
11
+ };
12
+ }
13
+ }
14
+ //# sourceMappingURL=xml.content-type-strategy.js.map
@@ -0,0 +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,CAAW,CAC7D;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { ThymianEmitter, ThymianFormat } from '@thymian/core';
2
+ import type { SamplesStructure } from '../samples-structure/samples-tree-structure.js';
3
+ export declare function generateSamplesForThymianFormat(format: ThymianFormat, emitter: ThymianEmitter): Promise<SamplesStructure>;
4
+ //# sourceMappingURL=generate-samples-for-thymian-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-samples-for-thymian-format.d.ts","sourceRoot":"","sources":["../../src/generation/generate-samples-for-thymian-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAGvF,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAiB3B"}
@@ -0,0 +1,18 @@
1
+ import { mergeTrees } from '../samples-structure/merge-tree.js';
2
+ import { generateSamplesTree } from './generate-samples.js';
3
+ export async function generateSamplesForThymianFormat(format, emitter) {
4
+ let samples = {
5
+ children: [],
6
+ meta: {
7
+ version: format.toHash(),
8
+ timestamp: 0,
9
+ },
10
+ type: 'root',
11
+ };
12
+ for (const t of format.getThymianHttpTransactions()) {
13
+ const tree = await generateSamplesTree(format, t, emitter);
14
+ samples = mergeTrees(samples, tree);
15
+ }
16
+ return samples;
17
+ }
18
+ //# sourceMappingURL=generate-samples-for-thymian-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-samples-for-thymian-format.js","sourceRoot":"","sources":["../../src/generation/generate-samples-for-thymian-format.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,MAAqB,EACrB,OAAuB;IAEvB,IAAI,OAAO,GAAqB;QAC9B,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YACxB,SAAS,EAAE,CAAC;SACb;QACD,IAAI,EAAE,MAAM;KACb,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,0BAA0B,EAAE,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ThymianEmitter, ThymianFormat, ThymianHttpTransaction } from '@thymian/core';
2
+ import type { SamplesStructure } from '../samples-structure/samples-tree-structure.js';
3
+ export declare function generateSamplesTree(format: ThymianFormat, transaction: ThymianHttpTransaction, emitter: ThymianEmitter): Promise<SamplesStructure>;
4
+ //# sourceMappingURL=generate-samples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-samples.d.ts","sourceRoot":"","sources":["../../src/generation/generate-samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAWvF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAyB3B"}
@@ -0,0 +1,26 @@
1
+ import { samplesTreeFromThymianHttpTransaction } from '../samples-structure/samples-from-transactions.js';
2
+ import { ContentSourceGenerator } from './content-source-generator.js';
3
+ import { HookContentTypeStrategy } from './content-type-strategies/hook.content-type-strategy.js';
4
+ import { ImageContentTypeStrategy } from './content-type-strategies/image.content-type-strategy.js';
5
+ import { JsonContentTypeStrategy } from './content-type-strategies/json.content-type-strategy.js';
6
+ import { PlainTextContentTypeStrategy } from './content-type-strategies/text.content-type-strategy.js';
7
+ import { XmlContentTypeStrategy } from './content-type-strategies/xml.content-type-strategy.js';
8
+ import { DefaultRequestGenerator } from './request-generators/default-request-generator.js';
9
+ import { RangeRequestGenerator } from './request-generators/range-request-generator.js';
10
+ import { UnauthorizedRequestGenerator } from './request-generators/unauthorized-request-generator.js';
11
+ export async function generateSamplesTree(format, transaction, emitter) {
12
+ const contentGenerator = new ContentSourceGenerator([
13
+ new JsonContentTypeStrategy(),
14
+ new XmlContentTypeStrategy(),
15
+ new ImageContentTypeStrategy(),
16
+ new PlainTextContentTypeStrategy(),
17
+ ], new HookContentTypeStrategy(emitter));
18
+ const generators = [
19
+ new RangeRequestGenerator(format, transaction, contentGenerator),
20
+ new UnauthorizedRequestGenerator(format, transaction, contentGenerator),
21
+ ];
22
+ const generator = generators.find((g) => g.matches()) ??
23
+ new DefaultRequestGenerator(format, transaction, contentGenerator);
24
+ return samplesTreeFromThymianHttpTransaction(await generator.generate(), transaction, format.toHash());
25
+ }
26
+ //# sourceMappingURL=generate-samples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-samples.js","sourceRoot":"","sources":["../../src/generation/generate-samples.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAEtG,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAqB,EACrB,WAAmC,EACnC,OAAuB;IAEvB,MAAM,gBAAgB,GAAG,IAAI,sBAAsB,CACjD;QACE,IAAI,uBAAuB,EAAE;QAC7B,IAAI,sBAAsB,EAAE;QAC5B,IAAI,wBAAwB,EAAE;QAC9B,IAAI,4BAA4B,EAAE;KACnC,EACD,IAAI,uBAAuB,CAAC,OAAO,CAAC,CACrC,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,IAAI,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC;QAChE,IAAI,4BAA4B,CAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC;KACxE,CAAC;IAEF,MAAM,SAAS,GACb,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAErE,OAAO,qCAAqC,CAC1C,MAAM,SAAS,CAAC,QAAQ,EAAE,EAC1B,WAAW,EACX,MAAM,CAAC,MAAM,EAAE,CAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Parameter, ThymianFormat, ThymianHttpTransaction } from '@thymian/core';
2
+ import type { ContentSource, HttpRequestSample } from '../../http-request-sample.js';
3
+ import type { ContentSourceGenerator } from '../content-source-generator.js';
4
+ export declare class DefaultRequestGenerator {
5
+ protected readonly format: ThymianFormat;
6
+ protected readonly transaction: ThymianHttpTransaction;
7
+ protected readonly contentGenerator: ContentSourceGenerator;
8
+ constructor(format: ThymianFormat, transaction: ThymianHttpTransaction, contentGenerator: ContentSourceGenerator);
9
+ matches(): boolean;
10
+ generate(): Promise<HttpRequestSample>;
11
+ protected shouldGenerateBody(): boolean;
12
+ protected generateParameters(parameters: Record<string, Parameter>): Promise<Record<string, ContentSource>>;
13
+ protected generateHeaders(): Promise<Record<string, ContentSource>>;
14
+ protected generateQueryParameters(): Promise<Record<string, ContentSource>>;
15
+ protected generatePathParameters(): Promise<Record<string, ContentSource>>;
16
+ protected generateCookies(): Promise<Record<string, ContentSource>>;
17
+ protected authorize(): boolean;
18
+ protected getHttpMethod(): string;
19
+ protected getPath(): string;
20
+ protected getOrigin(): string;
21
+ }
22
+ //# sourceMappingURL=default-request-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-request-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/request-generators/default-request-generator.ts"],"names":[],"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export class DefaultRequestGenerator {
2
+ format;
3
+ transaction;
4
+ contentGenerator;
5
+ constructor(format, transaction, contentGenerator) {
6
+ this.format = format;
7
+ this.transaction = transaction;
8
+ this.contentGenerator = contentGenerator;
9
+ }
10
+ matches() {
11
+ return false;
12
+ }
13
+ async generate() {
14
+ const requestSample = {
15
+ origin: this.getOrigin(),
16
+ path: this.getPath(),
17
+ pathParameters: await this.generatePathParameters(),
18
+ method: this.getHttpMethod(),
19
+ authorize: this.authorize(),
20
+ query: await this.generateQueryParameters(),
21
+ headers: await this.generateHeaders(),
22
+ cookies: await this.generateCookies(),
23
+ };
24
+ if (this.shouldGenerateBody() && this.transaction.thymianReq.body) {
25
+ requestSample.body = await this.contentGenerator.generate(this.transaction.thymianReq.mediaType, this.transaction.thymianReq.body);
26
+ }
27
+ return requestSample;
28
+ }
29
+ shouldGenerateBody() {
30
+ const { thymianReq } = this.transaction;
31
+ const methodsWithBody = ['POST', 'PUT', 'PATCH'];
32
+ return (!!thymianReq.body &&
33
+ (thymianReq.bodyRequired ||
34
+ methodsWithBody.some((m) => thymianReq.method.toUpperCase() === m)));
35
+ }
36
+ async generateParameters(parameters) {
37
+ const generated = {};
38
+ for (const [name, parameter] of Object.entries(parameters)) {
39
+ generated[name] = await this.contentGenerator.generate(parameter.contentType ?? 'application/json', parameter.schema);
40
+ }
41
+ return generated;
42
+ }
43
+ async generateHeaders() {
44
+ const headers = await this.generateParameters(this.transaction.thymianReq.headers);
45
+ const { mediaType } = this.transaction.thymianReq;
46
+ if (this.transaction.thymianReq.mediaType && this.shouldGenerateBody()) {
47
+ headers['content-type'] = {
48
+ $content: mediaType,
49
+ };
50
+ }
51
+ if (this.transaction.thymianRes?.mediaType) {
52
+ headers['accept'] = {
53
+ $content: this.transaction.thymianRes.mediaType,
54
+ };
55
+ }
56
+ return headers;
57
+ }
58
+ generateQueryParameters() {
59
+ return this.generateParameters(this.transaction.thymianReq.queryParameters);
60
+ }
61
+ generatePathParameters() {
62
+ return this.generateParameters(this.transaction.thymianReq.pathParameters);
63
+ }
64
+ generateCookies() {
65
+ return this.generateParameters(this.transaction.thymianReq.cookies);
66
+ }
67
+ authorize() {
68
+ return this.format.requestIsSecured(this.transaction.thymianReqId);
69
+ }
70
+ getHttpMethod() {
71
+ return this.transaction.thymianReq.method;
72
+ }
73
+ getPath() {
74
+ return this.transaction.thymianReq.path;
75
+ }
76
+ getOrigin() {
77
+ return `${this.transaction.thymianReq.protocol}://${this.transaction.thymianReq.host}:${this.transaction.thymianReq.port}`;
78
+ }
79
+ }
80
+ //# sourceMappingURL=default-request-generator.js.map
@@ -0,0 +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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,8 @@
1
+ import type { ContentSource } from '../../http-request-sample.js';
2
+ import { DefaultRequestGenerator } from './default-request-generator.js';
3
+ export declare class RangeRequestGenerator extends DefaultRequestGenerator {
4
+ private extractRangeUnit;
5
+ protected generateHeaders(): Promise<Record<string, ContentSource>>;
6
+ matches(): boolean;
7
+ }
8
+ //# sourceMappingURL=range-request-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range-request-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/request-generators/range-request-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,qBAAa,qBAAsB,SAAQ,uBAAuB;IAMhE,OAAO,CAAC,gBAAgB;cAIC,eAAe,IAAI,OAAO,CACjD,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAC9B;IAUQ,OAAO,IAAI,OAAO;CAG5B"}
@@ -0,0 +1,22 @@
1
+ import { DefaultRequestGenerator } from './default-request-generator.js';
2
+ export class RangeRequestGenerator extends DefaultRequestGenerator {
3
+ /*
4
+ The specification is intentionally kept open for range units types.
5
+ A logic that extracts the appropriate unit could be implemented here.
6
+ However, since `bytes` is the only official range unit, we simply use it.
7
+ */
8
+ extractRangeUnit() {
9
+ return 'bytes';
10
+ }
11
+ async generateHeaders() {
12
+ const headers = await super.generateHeaders();
13
+ headers['range'] = {
14
+ $content: `${this.extractRangeUnit()}=0-1`,
15
+ };
16
+ return headers;
17
+ }
18
+ matches() {
19
+ return this.transaction.thymianRes.statusCode === 206;
20
+ }
21
+ }
22
+ //# sourceMappingURL=range-request-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range-request-generator.js","sourceRoot":"","sources":["../../../src/generation/request-generators/range-request-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,OAAO,qBAAsB,SAAQ,uBAAuB;IAChE;;;;KAIC;IACO,gBAAgB;QACtB,OAAO,OAAO,CAAC;IACjB,CAAC;IAEkB,KAAK,CAAC,eAAe;QAGtC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;QAE9C,OAAO,CAAC,OAAO,CAAC,GAAG;YACjB,QAAQ,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM;SAC3C,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,OAAO;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,KAAK,GAAG,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { DefaultRequestGenerator } from './default-request-generator.js';
2
+ export declare class UnauthorizedRequestGenerator extends DefaultRequestGenerator {
3
+ matches(): boolean;
4
+ protected authorize(): boolean;
5
+ }
6
+ //# sourceMappingURL=unauthorized-request-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unauthorized-request-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/request-generators/unauthorized-request-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,qBAAa,4BAA6B,SAAQ,uBAAuB;IAC9D,OAAO,IAAI,OAAO;cAIR,SAAS,IAAI,OAAO;CAGxC"}
@@ -0,0 +1,10 @@
1
+ import { DefaultRequestGenerator } from './default-request-generator.js';
2
+ export class UnauthorizedRequestGenerator extends DefaultRequestGenerator {
3
+ matches() {
4
+ return this.transaction.thymianRes.statusCode === 401;
5
+ }
6
+ authorize() {
7
+ return false;
8
+ }
9
+ }
10
+ //# sourceMappingURL=unauthorized-request-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unauthorized-request-generator.js","sourceRoot":"","sources":["../../../src/generation/request-generators/unauthorized-request-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IAC9D,OAAO;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,KAAK,GAAG,CAAC;IACxD,CAAC;IAEkB,SAAS;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { type HttpRequest, type HttpRequestTemplate, type HttpResponse, type Logger, type ThymianFormat } from '@thymian/core';
2
+ import { type HttpTestCaseResult } from '@thymian/core';
3
+ import type { HookRunner } from './hook-runner.js';
4
+ import type { EndpointRequest, Endpoints, HookUtils } from './hook-utils.js';
5
+ export declare function toHttpRequestTemplate(methodAndUrl: string, req: EndpointRequest): HttpRequestTemplate;
6
+ export declare function createHookUtils<E extends Endpoints>(format: ThymianFormat, runRequest: (req: HttpRequest) => Promise<HttpResponse>, hookRunner: HookRunner, urlToTransactionId: Record<string, string>, results: HttpTestCaseResult[], logger: Logger): HookUtils<E>;
7
+ export declare function parseResponseBody(res: HttpResponse): unknown;
8
+ //# sourceMappingURL=create-hook-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-hook-utils.d.ts","sourceRoot":"","sources":["../../src/hooks/create-hook-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,eAAe,CAAC;AAG1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK7E,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,eAAe,GACnB,mBAAmB,CAsBrB;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EACjD,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,EACvD,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1C,OAAO,EAAE,kBAAkB,EAAE,EAC7B,MAAM,EAAE,MAAM,GACb,SAAS,CAAC,CAAC,CAAC,CAmId;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAW5D"}