@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.
@@ -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
- export type ImageContentTypeStrategyOptions = {
5
- width: number;
6
- height: number;
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(schema: ThymianSchema, contentType: string): Promise<ContentSource>;
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":"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"}
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 sharp from 'sharp';
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(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();
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 content.toBuffer(),
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":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,OAAO,wBAAwB;IAClB,OAAO,CAAkC;IAE1D,YAAY,UAAoD,EAAE;QAChE,IAAI,CAAC,OAAO,GAAG;YACb,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;YACX,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,WAAmB;QACzB,+DAA+D;QAC/D,OAAO,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IACD,KAAK,CAAC,QAAQ,CACZ,MAAqB,EACrB,WAAmB;QAEnB,IAAI,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE;YAC7C,GAAG,EAAE;gBACH,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;gBAC3B,QAAQ,EAAE,CAAC;aACZ;SACF,CAAC,CAAC;QAEH,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;YAC1C,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACf,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEnB,OAAO;YACL,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,MAAM,OAAO,CAAC,QAAQ,EAAE;YACjC,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;IAEO,kBAAkB;QACxB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAE1E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
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.20260729-e8d85b6",
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.20260729-e8d85b6",
46
- "@thymian/core": "0.1.13-canary.20260729-e8d85b6",
47
- "@thymian/plugin-request-dispatcher": "0.1.13-canary.20260729-e8d85b6",
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.20260729-e8d85b6",
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
  }