@thymian/plugin-sampler 0.1.13-canary.20260729-e8d85b6 → 0.1.13-canary.20260730-72ecb30
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.
- package/dist/generation/content-type-strategies/assets/sample-256.jpg +0 -0
- package/dist/generation/content-type-strategies/assets/sample-256.png +0 -0
- package/dist/generation/content-type-strategies/image.content-type-strategy.d.ts +8 -8
- package/dist/generation/content-type-strategies/image.content-type-strategy.d.ts.map +1 -1
- package/dist/generation/content-type-strategies/image.content-type-strategy.js +15 -30
- package/dist/generation/content-type-strategies/image.content-type-strategy.js.map +1 -1
- package/package.json +5 -6
|
Binary file
|
|
Binary file
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ThymianSchema } from '@thymian/core';
|
|
2
2
|
import type { ContentSource } from '../../http-request-sample.js';
|
|
3
3
|
import type { ContentTypeStrategy } from './content-type-strategy.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Produces a placeholder body for image/* request bodies. The bytes come from
|
|
6
|
+
* pre-generated static assets (256x256 solid colour) read from disk instead of
|
|
7
|
+
* being synthesised at runtime, so the package carries no image-processing
|
|
8
|
+
* dependency. The content is throwaway placeholder data, so fixed bytes are
|
|
9
|
+
* behaviourally equivalent to the previous random-pixel generation.
|
|
10
|
+
*/
|
|
8
11
|
export declare class ImageContentTypeStrategy implements ContentTypeStrategy {
|
|
9
|
-
private readonly options;
|
|
10
|
-
constructor(options?: Partial<ImageContentTypeStrategyOptions>);
|
|
11
12
|
matches(contentType: string): boolean;
|
|
12
|
-
generate(
|
|
13
|
-
private randomPixelsBuffer;
|
|
13
|
+
generate(_schema: ThymianSchema, contentType: string): Promise<ContentSource>;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=image.content-type-strategy.d.ts.map
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"image.content-type-strategy.d.ts","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/image.content-type-strategy.ts"],"names":[],"mappings":"AAGA,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;AAItE;;;;;;GAMG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAClE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CACZ,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC;CAU1B"}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const ASSETS_DIR = join(import.meta.dirname, 'assets');
|
|
4
|
+
/**
|
|
5
|
+
* Produces a placeholder body for image/* request bodies. The bytes come from
|
|
6
|
+
* pre-generated static assets (256x256 solid colour) read from disk instead of
|
|
7
|
+
* being synthesised at runtime, so the package carries no image-processing
|
|
8
|
+
* dependency. The content is throwaway placeholder data, so fixed bytes are
|
|
9
|
+
* behaviourally equivalent to the previous random-pixel generation.
|
|
10
|
+
*/
|
|
2
11
|
export class ImageContentTypeStrategy {
|
|
3
|
-
options;
|
|
4
|
-
constructor(options = {}) {
|
|
5
|
-
this.options = {
|
|
6
|
-
width: 256,
|
|
7
|
-
height: 256,
|
|
8
|
-
...options,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
12
|
matches(contentType) {
|
|
12
|
-
// TODO: fill regex https://sharp.pixelplumbing.com/api-output/
|
|
13
13
|
return /^image\/(jpeg|png|jpg)/i.test(contentType);
|
|
14
14
|
}
|
|
15
|
-
async generate(
|
|
16
|
-
|
|
17
|
-
|
|
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();
|
|
15
|
+
async generate(_schema, contentType) {
|
|
16
|
+
const isPng = /^image\/png/i.test(contentType);
|
|
17
|
+
const asset = isPng ? 'sample-256.png' : 'sample-256.jpg';
|
|
26
18
|
return {
|
|
27
19
|
$encoding: 'base64',
|
|
28
|
-
$buffer: await
|
|
29
|
-
$ext: 'png',
|
|
20
|
+
$buffer: await readFile(join(ASSETS_DIR, asset)),
|
|
21
|
+
$ext: isPng ? 'png' : 'jpg',
|
|
30
22
|
};
|
|
31
23
|
}
|
|
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
24
|
}
|
|
40
25
|
//# sourceMappingURL=image.content-type-strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/image.content-type-strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.content-type-strategy.js","sourceRoot":"","sources":["../../../src/generation/content-type-strategies/image.content-type-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,OAAO,wBAAwB;IACnC,OAAO,CAAC,WAAmB;QACzB,OAAO,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAsB,EACtB,WAAmB;QAEnB,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAE1D,OAAO;YACL,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAChD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;SAC5B,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thymian/plugin-sampler",
|
|
3
|
-
"version": "0.1.13-canary.
|
|
3
|
+
"version": "0.1.13-canary.20260730-72ecb30",
|
|
4
4
|
"description": "Thymian plugin for generating HTTP request samples from API descriptions",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"bugs": {
|
|
@@ -42,15 +42,14 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@scalar/json-magic": "^0.9.0",
|
|
45
|
-
"@thymian/common-cli": "0.1.13-canary.
|
|
46
|
-
"@thymian/core": "0.1.13-canary.
|
|
47
|
-
"@thymian/plugin-request-dispatcher": "0.1.13-canary.
|
|
45
|
+
"@thymian/common-cli": "0.1.13-canary.20260730-72ecb30",
|
|
46
|
+
"@thymian/core": "0.1.13-canary.20260730-72ecb30",
|
|
47
|
+
"@thymian/plugin-request-dispatcher": "0.1.13-canary.20260730-72ecb30",
|
|
48
48
|
"code-block-writer": "^13.0.3",
|
|
49
49
|
"jiti": "^2.6.1",
|
|
50
50
|
"json-schema-to-typescript": "^15.0.4",
|
|
51
51
|
"launch-editor": "^2.14.1",
|
|
52
52
|
"openapi-sampler": "^1.7.2",
|
|
53
|
-
"sharp": "^0.35.0",
|
|
54
53
|
"tslib": "^2.3.0"
|
|
55
54
|
},
|
|
56
55
|
"oclif": {
|
|
@@ -64,7 +63,7 @@
|
|
|
64
63
|
}
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@thymian/core-testing": "0.1.13-canary.
|
|
66
|
+
"@thymian/core-testing": "0.1.13-canary.20260730-72ecb30",
|
|
68
67
|
"fast-json-stable-stringify": "^2.1.0",
|
|
69
68
|
"ts-morph": "^27.0.2"
|
|
70
69
|
}
|