@thymian/plugin-request-dispatcher 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.
- package/README.md +59 -0
- package/dist/decode-body.d.ts +3 -0
- package/dist/decode-body.d.ts.map +1 -0
- package/dist/decode-body.js +16 -0
- package/dist/decode-body.js.map +1 -0
- package/dist/dispatch.d.ts +8 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +46 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +68 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!-- HEADER:START - Do not remove or modify this section -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/thymianofficial/thymian/main/astro-docs/src/assets/logo.svg" alt="Thymian Logo" width="200"/>
|
|
4
|
+
|
|
5
|
+
# Thymian
|
|
6
|
+
|
|
7
|
+
**Add resilience and HTTP conformance to your API development workflow**
|
|
8
|
+
|
|
9
|
+
[](https://github.com/thymianofficial/thymian/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/thymianofficial/thymian/actions/workflows/ci.yaml)
|
|
11
|
+
[](https://thymian.dev)
|
|
12
|
+
[](https://discord.gg/TRSwCxbz9f)
|
|
13
|
+
[](https://www.reddit.com/r/ThymianOfficial/)
|
|
14
|
+
[](https://x.com/thymiandev)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
<!-- HEADER:END -->
|
|
18
|
+
|
|
19
|
+
## @thymian/plugin-request-dispatcher
|
|
20
|
+
|
|
21
|
+
Dispatches HTTP requests to live API endpoints during `thymian test` runs. Constructs requests from Thymian's internal format, sends them to the target URL, and captures the responses for rule evaluation.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @thymian/plugin-request-dispatcher
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Getting started with Thymian?** See the [main Thymian package](https://www.npmjs.com/package/thymian) for quick installation and first-run instructions.
|
|
30
|
+
|
|
31
|
+
<!-- FOOTER:START - Do not remove or modify this section -->
|
|
32
|
+
|
|
33
|
+
## 📚 Documentation
|
|
34
|
+
|
|
35
|
+
- **[Getting Started](https://thymian.dev/introduction/getting-started)** - Set up Thymian in minutes
|
|
36
|
+
- **[Documentation](https://thymian.dev)** - Comprehensive guides and API reference
|
|
37
|
+
- **[CLI Reference](https://thymian.dev/references/cli)** - Complete CLI command documentation
|
|
38
|
+
- **[HTTP Rules](https://thymian.dev/guides/http-rules/how-to-use-rules)** - Learn about HTTP conformance validation
|
|
39
|
+
|
|
40
|
+
## 🏢 Enterprise Support
|
|
41
|
+
|
|
42
|
+
Get professional consulting and dedicated support from the creators of Thymian. We offer:
|
|
43
|
+
|
|
44
|
+
- API design and governance strategies
|
|
45
|
+
- HTTP standards compliance auditing
|
|
46
|
+
- Custom plugin development
|
|
47
|
+
- Custom rule development
|
|
48
|
+
- Team training and workshops
|
|
49
|
+
|
|
50
|
+
**[Learn more about Enterprise Support](https://thymian.dev/enterprise)** | **Email: [support@thymian.dev](mailto:support@thymian.dev)**
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<div align="center">
|
|
55
|
+
|
|
56
|
+
**Shipped with 🌱 by [qupaya](https://qupaya.com)**
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
<!-- FOOTER:END -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-body.d.ts","sourceRoot":"","sources":["../src/decode-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAehD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
export function decodeBody(body, encoding) {
|
|
3
|
+
if (typeof body !== 'string') {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
if (!encoding) {
|
|
7
|
+
return body;
|
|
8
|
+
}
|
|
9
|
+
switch (encoding) {
|
|
10
|
+
case 'base64':
|
|
11
|
+
return Buffer.from(body, 'base64');
|
|
12
|
+
default:
|
|
13
|
+
throw new Error(`Unknown encoding ${encoding}.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=decode-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-body.js","sourceRoot":"","sources":["../src/decode-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,UAAU,UAAU,CACxB,IAAa,EACb,QAAiB;IAEjB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from '@thymian/core';
|
|
2
|
+
import type { HttpMethod } from './types.js';
|
|
3
|
+
export declare function isValidHttpMethod(method: string): method is HttpMethod;
|
|
4
|
+
export type HttpRequestDispatchOptions = {
|
|
5
|
+
timeout: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function dispatchHttpRequest(httpRequest: HttpRequest, options?: Partial<HttpRequestDispatchOptions>): Promise<HttpResponse>;
|
|
8
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,UAAU,CAYtE;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAChD,OAAO,CAAC,YAAY,CAAC,CAwCvB"}
|
package/dist/dispatch.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { request } from 'undici';
|
|
2
|
+
import { decodeBody } from './decode-body.js';
|
|
3
|
+
export function isValidHttpMethod(method) {
|
|
4
|
+
return [
|
|
5
|
+
'GET',
|
|
6
|
+
'POST',
|
|
7
|
+
'PUT',
|
|
8
|
+
'DELETE',
|
|
9
|
+
'PATCH',
|
|
10
|
+
'OPTIONS',
|
|
11
|
+
'HEAD',
|
|
12
|
+
'CONNECT',
|
|
13
|
+
'TRACE',
|
|
14
|
+
].includes(method.toUpperCase());
|
|
15
|
+
}
|
|
16
|
+
export async function dispatchHttpRequest(httpRequest, options = {}) {
|
|
17
|
+
const opts = {
|
|
18
|
+
timeout: 5000,
|
|
19
|
+
...options,
|
|
20
|
+
};
|
|
21
|
+
const method = httpRequest.method.toUpperCase();
|
|
22
|
+
if (!isValidHttpMethod(method)) {
|
|
23
|
+
throw new Error('Invalid HTTP method.');
|
|
24
|
+
}
|
|
25
|
+
const start = performance.now();
|
|
26
|
+
const response = await request(new URL(httpRequest.path, httpRequest.origin).toString(), {
|
|
27
|
+
method,
|
|
28
|
+
headers: httpRequest.headers,
|
|
29
|
+
body: decodeBody(httpRequest.body, httpRequest.bodyEncoding),
|
|
30
|
+
bodyTimeout: opts.timeout,
|
|
31
|
+
headersTimeout: opts.timeout,
|
|
32
|
+
});
|
|
33
|
+
const res = {
|
|
34
|
+
bodyEncoding: '',
|
|
35
|
+
duration: performance.now() - start,
|
|
36
|
+
headers: response.headers,
|
|
37
|
+
statusCode: response.statusCode,
|
|
38
|
+
trailers: response.trailers,
|
|
39
|
+
};
|
|
40
|
+
const body = await response.body.text();
|
|
41
|
+
if (body) {
|
|
42
|
+
res.body = body;
|
|
43
|
+
}
|
|
44
|
+
return res;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO;QACL,KAAK;QACL,MAAM;QACN,KAAK;QACL,QAAQ;QACR,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;QACT,OAAO;KACR,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACnC,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,UAA+C,EAAE;IAEjD,MAAM,IAAI,GAAG;QACX,OAAO,EAAE,IAAI;QACb,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAEhD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAEhC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EACxD;QACE,MAAM;QACN,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC;QAC5D,WAAW,EAAE,IAAI,CAAC,OAAO;QACzB,cAAc,EAAE,IAAI,CAAC,OAAO;KAC7B,CACF,CAAC;IAEF,MAAM,GAAG,GAAiB;QACxB,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK;QACnC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAExC,IAAI,IAAI,EAAE,CAAC;QACT,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ThymianPlugin } from '@thymian/core';
|
|
2
|
+
export interface HttpRequestError extends Error {
|
|
3
|
+
code: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function isHttpRequestError(err: unknown): err is HttpRequestError;
|
|
6
|
+
export type SamplerPluginOptions = {
|
|
7
|
+
concurrency?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const dispatcherPlugin: ThymianPlugin<SamplerPluginOptions>;
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export default dispatcherPlugin;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAKrE,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAExE;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,oBAAoB,CAwDhE,CAAC;AAEF,cAAc,YAAY,CAAC;AAC3B,eAAe,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ThymianBaseError } from '@thymian/core';
|
|
2
|
+
import PQueue from 'p-queue';
|
|
3
|
+
import { dispatchHttpRequest } from './dispatch.js';
|
|
4
|
+
export function isHttpRequestError(err) {
|
|
5
|
+
return err instanceof Error && 'code' in err;
|
|
6
|
+
}
|
|
7
|
+
export const dispatcherPlugin = {
|
|
8
|
+
name: '@thymian/plugin-request-dispatcher',
|
|
9
|
+
version: '0.x',
|
|
10
|
+
options: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
concurrency: { type: 'integer', nullable: true },
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
actions: {
|
|
17
|
+
listensOn: ['core.request.dispatch'],
|
|
18
|
+
},
|
|
19
|
+
events: {},
|
|
20
|
+
plugin: async (emitter, logger, opts) => {
|
|
21
|
+
const queue = new PQueue({ concurrency: opts?.concurrency ?? 10 });
|
|
22
|
+
emitter.onAction('core.close', async (_, ctx) => {
|
|
23
|
+
await queue.onIdle();
|
|
24
|
+
ctx.reply();
|
|
25
|
+
});
|
|
26
|
+
emitter.onAction('core.request.dispatch', async ({ request, options }, ctx) => {
|
|
27
|
+
try {
|
|
28
|
+
const result = await queue.add(() => dispatchHttpRequest(request, options));
|
|
29
|
+
ctx.reply(result);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (isHttpRequestError(e) && e.code === 'ECONNREFUSED') {
|
|
33
|
+
return ctx.error(new ThymianBaseError(`Server ${request.origin} is unavailable.`, {
|
|
34
|
+
name: 'ServerUnavailableError',
|
|
35
|
+
ref: 'https://thymian.dev/references/errors/server-unavailable-error/',
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
ctx.error(new ThymianBaseError(`Error while dispatching request: ${request.method.toUpperCase()} ${request.origin}.`, {
|
|
39
|
+
name: 'RequestDispatchError',
|
|
40
|
+
ref: 'https://thymian.dev/references/errors/request-dispatch-error/',
|
|
41
|
+
cause: e,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export * from './types.js';
|
|
48
|
+
export default dispatcherPlugin;
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AACrE,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,GAAG,YAAY,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC;AAC/C,CAAC;AAMD,MAAM,CAAC,MAAM,gBAAgB,GAAwC;IACnE,IAAI,EAAE,oCAAoC;IAC1C,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;SACjD;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAE,CAAC,uBAAuB,CAAC;KACrC;IACD,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE,EAAE,CAAC,CAAC;QAEnE,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;YAC9C,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;YAErB,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,QAAQ,CACd,uBAAuB,EACvB,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE;YAClC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAClC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CACtC,CAAC;gBAEF,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;YAAC,OAAO,CAAU,EAAE,CAAC;gBACpB,IAAI,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBACvD,OAAO,GAAG,CAAC,KAAK,CACd,IAAI,gBAAgB,CAAC,UAAU,OAAO,CAAC,MAAM,kBAAkB,EAAE;wBAC/D,IAAI,EAAE,wBAAwB;wBAC9B,GAAG,EAAE,iEAAiE;qBACvE,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,GAAG,CAAC,KAAK,CACP,IAAI,gBAAgB,CAClB,oCAAoC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,IAC9D,OAAO,CAAC,MACV,GAAG,EACH;oBACE,IAAI,EAAE,sBAAsB;oBAC5B,GAAG,EAAE,+DAA+D;oBACpE,KAAK,EAAE,CAAC;iBACT,CACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,cAAc,YAAY,CAAC;AAC3B,eAAe,gBAAgB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from '@thymian/core';
|
|
2
|
+
import type { JSONSchemaType } from '@thymian/core/ajv';
|
|
3
|
+
import type { Dispatcher } from 'undici';
|
|
4
|
+
export declare const httpRequestSchema: JSONSchemaType<HttpRequest>;
|
|
5
|
+
export declare const httpResponseSchema: JSONSchemaType<HttpResponse>;
|
|
6
|
+
export type HttpMethod = Dispatcher.RequestOptions['method'];
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CA8BzD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CAmClD,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const httpRequestSchema = {
|
|
2
|
+
type: 'object',
|
|
3
|
+
properties: {
|
|
4
|
+
origin: { type: 'string', nullable: false },
|
|
5
|
+
path: { type: 'string', nullable: false },
|
|
6
|
+
method: { type: 'string', nullable: false },
|
|
7
|
+
body: { type: 'string', nullable: true },
|
|
8
|
+
bodyEncoding: { type: 'string', nullable: true },
|
|
9
|
+
headers: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
required: [],
|
|
12
|
+
nullable: true,
|
|
13
|
+
additionalProperties: {
|
|
14
|
+
oneOf: [
|
|
15
|
+
{
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'string',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
timeout: { type: 'number', nullable: true },
|
|
28
|
+
},
|
|
29
|
+
required: ['origin', 'method', 'path'],
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
};
|
|
32
|
+
export const httpResponseSchema = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
statusCode: { type: 'integer', nullable: false },
|
|
36
|
+
headers: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
required: [],
|
|
39
|
+
additionalProperties: {
|
|
40
|
+
oneOf: [
|
|
41
|
+
{
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'string',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
body: { type: 'string', nullable: true },
|
|
54
|
+
bodyEncoding: { type: 'string', nullable: true },
|
|
55
|
+
trailers: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
required: [],
|
|
58
|
+
additionalProperties: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
nullable: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
duration: { type: 'number', nullable: false },
|
|
64
|
+
},
|
|
65
|
+
required: ['statusCode', 'headers', 'trailers', 'duration'],
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC3C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QACzC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC3C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAChD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE;gBACpB,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;QACD,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5C;IACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;IACtC,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE;QAChD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE;gBACpB,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;QACD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAChD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE;gBACpB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,KAAK;aAChB;SACF;QACD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;KAC9C;IACD,QAAQ,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;IAC3D,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thymian/plugin-request-dispatcher",
|
|
3
|
+
"version": "0.0.0-PLACEHOLDER",
|
|
4
|
+
"description": "Thymian plugin for dispatching HTTP requests with concurrency control",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/thymianofficial/thymian/issues"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://thymian.dev",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/thymianofficial/thymian.git",
|
|
13
|
+
"directory": "packages/plugin-request-dispatcher"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"thymian",
|
|
20
|
+
"api-testing",
|
|
21
|
+
"http-client",
|
|
22
|
+
"http-request",
|
|
23
|
+
"request-dispatcher"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!**/*.tsbuildinfo"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"typings": "./dist/index.d.ts",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@thymian/core": "0.0.0-PLACEHOLDER",
|
|
34
|
+
"async-mutex": "^0.5.0",
|
|
35
|
+
"p-queue": "^9.0.1",
|
|
36
|
+
"undici": "^6.24.0"
|
|
37
|
+
}
|
|
38
|
+
}
|