@c9up/ream 0.1.25 → 0.1.27
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 +65 -0
- package/dist/ConfigLoader.d.ts +46 -5
- package/dist/ConfigLoader.d.ts.map +1 -1
- package/dist/ConfigLoader.js +60 -9
- package/dist/ConfigLoader.js.map +1 -1
- package/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +46 -6
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts +115 -7
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +254 -40
- package/dist/Ignitor.js.map +1 -1
- package/dist/console/BaseCommand.d.ts +217 -0
- package/dist/console/BaseCommand.d.ts.map +1 -0
- package/dist/console/BaseCommand.js +340 -0
- package/dist/console/BaseCommand.js.map +1 -0
- package/dist/console/Console.d.ts +86 -0
- package/dist/console/Console.d.ts.map +1 -0
- package/dist/console/Console.js +134 -0
- package/dist/console/Console.js.map +1 -0
- package/dist/console/ExceptionHandler.d.ts +28 -0
- package/dist/console/ExceptionHandler.d.ts.map +1 -0
- package/dist/console/ExceptionHandler.js +76 -0
- package/dist/console/ExceptionHandler.js.map +1 -0
- package/dist/console/HelpCommand.d.ts +16 -0
- package/dist/console/HelpCommand.d.ts.map +1 -0
- package/dist/console/HelpCommand.js +40 -0
- package/dist/console/HelpCommand.js.map +1 -0
- package/dist/console/IndexGenerator.d.ts +24 -0
- package/dist/console/IndexGenerator.d.ts.map +1 -0
- package/dist/console/IndexGenerator.js +65 -0
- package/dist/console/IndexGenerator.js.map +1 -0
- package/dist/console/Kernel.d.ts +298 -0
- package/dist/console/Kernel.d.ts.map +1 -0
- package/dist/console/Kernel.js +1120 -0
- package/dist/console/Kernel.js.map +1 -0
- package/dist/console/ListCommand.d.ts +18 -0
- package/dist/console/ListCommand.d.ts.map +1 -0
- package/dist/console/ListCommand.js +60 -0
- package/dist/console/ListCommand.js.map +1 -0
- package/dist/console/assertions.d.ts +20 -0
- package/dist/console/assertions.d.ts.map +1 -0
- package/dist/console/assertions.js +84 -0
- package/dist/console/assertions.js.map +1 -0
- package/dist/console/cliui.d.ts +248 -0
- package/dist/console/cliui.d.ts.map +1 -0
- package/dist/console/cliui.js +587 -0
- package/dist/console/cliui.js.map +1 -0
- package/dist/console/decorators.d.ts +90 -0
- package/dist/console/decorators.d.ts.map +1 -0
- package/dist/console/decorators.js +142 -0
- package/dist/console/decorators.js.map +1 -0
- package/dist/console/index.d.ts +32 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/console/index.js +24 -0
- package/dist/console/index.js.map +1 -0
- package/dist/console/loaders.d.ts +52 -0
- package/dist/console/loaders.d.ts.map +1 -0
- package/dist/console/loaders.js +131 -0
- package/dist/console/loaders.js.map +1 -0
- package/dist/console/parser.d.ts +86 -0
- package/dist/console/parser.d.ts.map +1 -0
- package/dist/console/parser.js +440 -0
- package/dist/console/parser.js.map +1 -0
- package/dist/console/prompts.d.ts +124 -0
- package/dist/console/prompts.d.ts.map +1 -0
- package/dist/console/prompts.js +356 -0
- package/dist/console/prompts.js.map +1 -0
- package/dist/console/tracing.d.ts +17 -0
- package/dist/console/tracing.d.ts.map +1 -0
- package/dist/console/tracing.js +11 -0
- package/dist/console/tracing.js.map +1 -0
- package/dist/console/types.d.ts +255 -0
- package/dist/console/types.d.ts.map +1 -0
- package/dist/console/types.js +25 -0
- package/dist/console/types.js.map +1 -0
- package/dist/console/ui.d.ts +20 -0
- package/dist/console/ui.d.ts.map +1 -0
- package/dist/console/ui.js +31 -0
- package/dist/console/ui.js.map +1 -0
- package/dist/console/utils.d.ts +27 -0
- package/dist/console/utils.d.ts.map +1 -0
- package/dist/console/utils.js +56 -0
- package/dist/console/utils.js.map +1 -0
- package/dist/container/Container.d.ts +23 -3
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +177 -70
- package/dist/container/Container.js.map +1 -1
- package/dist/container/types.d.ts +14 -2
- package/dist/container/types.d.ts.map +1 -1
- package/dist/decorators/Service.d.ts +7 -0
- package/dist/decorators/Service.d.ts.map +1 -1
- package/dist/decorators/Service.js +23 -3
- package/dist/decorators/Service.js.map +1 -1
- package/dist/env/Env.d.ts +29 -4
- package/dist/env/Env.d.ts.map +1 -1
- package/dist/env/Env.js +27 -4
- package/dist/env/Env.js.map +1 -1
- package/dist/env/Secret.d.ts +11 -0
- package/dist/env/Secret.d.ts.map +1 -0
- package/dist/env/Secret.js +36 -0
- package/dist/env/Secret.js.map +1 -0
- package/dist/env/interpolate.d.ts +26 -0
- package/dist/env/interpolate.d.ts.map +1 -0
- package/dist/env/interpolate.js +48 -0
- package/dist/env/interpolate.js.map +1 -0
- package/dist/env/loadEnvFiles.d.ts.map +1 -1
- package/dist/env/loadEnvFiles.js +14 -4
- package/dist/env/loadEnvFiles.js.map +1 -1
- package/dist/env/schema.d.ts +23 -6
- package/dist/env/schema.d.ts.map +1 -1
- package/dist/env/schema.js +67 -33
- package/dist/env/schema.js.map +1 -1
- package/dist/errors/ReamError.d.ts +25 -0
- package/dist/errors/ReamError.d.ts.map +1 -1
- package/dist/errors/ReamError.js +5 -0
- package/dist/errors/ReamError.js.map +1 -1
- package/dist/errors/prettyPrintError.d.ts +9 -0
- package/dist/errors/prettyPrintError.d.ts.map +1 -0
- package/dist/errors/prettyPrintError.js +22 -0
- package/dist/errors/prettyPrintError.js.map +1 -0
- package/dist/events/Emitter.d.ts +1 -1
- package/dist/events/Emitter.d.ts.map +1 -1
- package/dist/events/Emitter.js +1 -1
- package/dist/events/Emitter.js.map +1 -1
- package/dist/events/EventsProvider.d.ts +2 -2
- package/dist/events/EventsProvider.d.ts.map +1 -1
- package/dist/events/EventsProvider.js +3 -3
- package/dist/events/EventsProvider.js.map +1 -1
- package/dist/graphql/GraphQLEngine.d.ts +1 -1
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
- package/dist/graphql/GraphQLEngine.js +2 -2
- package/dist/graphql/GraphQLEngine.js.map +1 -1
- package/dist/graphql/GraphQLProvider.d.ts.map +1 -1
- package/dist/graphql/GraphQLProvider.js +7 -3
- package/dist/graphql/GraphQLProvider.js.map +1 -1
- package/dist/http/Exception.d.ts +63 -1
- package/dist/http/Exception.d.ts.map +1 -1
- package/dist/http/Exception.js +185 -48
- package/dist/http/Exception.js.map +1 -1
- package/dist/http/HttpContext.d.ts +53 -7
- package/dist/http/HttpContext.d.ts.map +1 -1
- package/dist/http/HttpContext.js +56 -15
- package/dist/http/HttpContext.js.map +1 -1
- package/dist/http/RedirectBuilder.d.ts.map +1 -1
- package/dist/http/RedirectBuilder.js +4 -1
- package/dist/http/RedirectBuilder.js.map +1 -1
- package/dist/http/Request.d.ts +141 -10
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +244 -34
- package/dist/http/Request.js.map +1 -1
- package/dist/http/Response.d.ts +176 -9
- package/dist/http/Response.d.ts.map +1 -1
- package/dist/http/Response.js +404 -16
- package/dist/http/Response.js.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware/Pipeline.d.ts +29 -8
- package/dist/middleware/Pipeline.d.ts.map +1 -1
- package/dist/middleware/Pipeline.js +40 -2
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/openapi/OpenApiProvider.js +4 -4
- package/dist/openapi/OpenApiProvider.js.map +1 -1
- package/dist/router/Router.d.ts +223 -31
- package/dist/router/Router.d.ts.map +1 -1
- package/dist/router/Router.js +520 -102
- package/dist/router/Router.js.map +1 -1
- package/dist/rpc/RpcProvider.d.ts +1 -0
- package/dist/rpc/RpcProvider.d.ts.map +1 -1
- package/dist/rpc/RpcProvider.js +7 -3
- package/dist/rpc/RpcProvider.js.map +1 -1
- package/dist/rpc/RpcRouter.d.ts +2 -2
- package/dist/rpc/RpcRouter.d.ts.map +1 -1
- package/dist/rpc/RpcRouter.js +17 -5
- package/dist/rpc/RpcRouter.js.map +1 -1
- package/dist/scheduler/ScheduleProvider.d.ts.map +1 -1
- package/dist/scheduler/ScheduleProvider.js +7 -15
- package/dist/scheduler/ScheduleProvider.js.map +1 -1
- package/dist/server/Server.d.ts +17 -4
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js +41 -7
- package/dist/server/Server.js.map +1 -1
- package/dist/services/app.d.ts +1 -1
- package/dist/services/app.js +1 -1
- package/dist/services/console.d.ts +21 -0
- package/dist/services/console.d.ts.map +1 -0
- package/dist/services/console.js +35 -0
- package/dist/services/console.js.map +1 -0
- package/dist/session/SessionMiddleware.js +3 -3
- package/dist/session/SessionMiddleware.js.map +1 -1
- package/dist/storage/StaticProvider.js +1 -1
- package/dist/storage/StaticProvider.js.map +1 -1
- package/dist/testing/ApiResponse.d.ts +218 -0
- package/dist/testing/ApiResponse.d.ts.map +1 -0
- package/dist/testing/ApiResponse.js +576 -0
- package/dist/testing/ApiResponse.js.map +1 -0
- package/dist/testing/RequestBuilder.d.ts +155 -35
- package/dist/testing/RequestBuilder.d.ts.map +1 -1
- package/dist/testing/RequestBuilder.js +455 -109
- package/dist/testing/RequestBuilder.js.map +1 -1
- package/dist/testing/TestClient.d.ts +53 -37
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +84 -52
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/utils/Macroable.d.ts +30 -0
- package/dist/utils/Macroable.d.ts.map +1 -0
- package/dist/utils/Macroable.js +43 -0
- package/dist/utils/Macroable.js.map +1 -0
- package/dist/utils/inflect.d.ts +17 -0
- package/dist/utils/inflect.d.ts.map +1 -0
- package/dist/utils/inflect.js +32 -0
- package/dist/utils/inflect.js.map +1 -0
- package/dist/utils/objectPath.d.ts +57 -0
- package/dist/utils/objectPath.d.ts.map +1 -0
- package/dist/utils/objectPath.js +141 -0
- package/dist/utils/objectPath.js.map +1 -0
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +20 -2
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/ConfigLoader.ts +72 -9
- package/src/HttpKernel.ts +53 -15
- package/src/Ignitor.ts +364 -45
- package/src/console/BaseCommand.ts +467 -0
- package/src/console/Console.ts +174 -0
- package/src/console/ExceptionHandler.ts +91 -0
- package/src/console/HelpCommand.ts +37 -0
- package/src/console/IndexGenerator.ts +79 -0
- package/src/console/Kernel.ts +1382 -0
- package/src/console/ListCommand.ts +55 -0
- package/src/console/assertions.ts +114 -0
- package/src/console/cliui.ts +756 -0
- package/src/console/decorators.ts +199 -0
- package/src/console/index.ts +67 -0
- package/src/console/loaders.ts +145 -0
- package/src/console/parser.ts +598 -0
- package/src/console/prompts.ts +548 -0
- package/src/console/tracing.ts +22 -0
- package/src/console/types.ts +280 -0
- package/src/console/ui.ts +37 -0
- package/src/console/utils.ts +69 -0
- package/src/container/Container.ts +198 -72
- package/src/container/types.ts +15 -2
- package/src/decorators/Service.ts +28 -3
- package/src/env/Env.ts +49 -5
- package/src/env/Secret.ts +41 -0
- package/src/env/interpolate.ts +54 -0
- package/src/env/loadEnvFiles.ts +12 -4
- package/src/env/schema.ts +109 -35
- package/src/errors/ReamError.ts +31 -0
- package/src/errors/prettyPrintError.ts +20 -0
- package/src/events/Emitter.ts +2 -2
- package/src/events/EventsProvider.ts +5 -5
- package/src/graphql/GraphQLEngine.ts +4 -4
- package/src/graphql/GraphQLProvider.ts +7 -3
- package/src/http/Exception.ts +214 -37
- package/src/http/HttpContext.ts +87 -18
- package/src/http/RedirectBuilder.ts +4 -1
- package/src/http/Request.ts +264 -34
- package/src/http/Response.ts +478 -27
- package/src/index.ts +41 -6
- package/src/middleware/Pipeline.ts +77 -6
- package/src/openapi/OpenApiProvider.ts +4 -4
- package/src/router/Router.ts +631 -113
- package/src/rpc/RpcProvider.ts +6 -2
- package/src/rpc/RpcRouter.ts +22 -7
- package/src/scheduler/ScheduleProvider.ts +7 -15
- package/src/server/Server.ts +49 -10
- package/src/services/app.ts +1 -1
- package/src/services/console.ts +42 -0
- package/src/session/SessionMiddleware.ts +4 -4
- package/src/storage/StaticProvider.ts +1 -1
- package/src/testing/ApiResponse.ts +691 -0
- package/src/testing/RequestBuilder.ts +577 -137
- package/src/testing/TestClient.ts +110 -77
- package/src/utils/Macroable.ts +54 -0
- package/src/utils/inflect.ts +29 -0
- package/src/utils/objectPath.ts +142 -0
- package/dist/console/CommandRunner.d.ts +0 -18
- package/dist/console/CommandRunner.d.ts.map +0 -1
- package/dist/console/CommandRunner.js +0 -65
- package/dist/console/CommandRunner.js.map +0 -1
- package/dist/decorators/Lazy.d.ts +0 -19
- package/dist/decorators/Lazy.d.ts.map +0 -1
- package/dist/decorators/Lazy.js +0 -53
- package/dist/decorators/Lazy.js.map +0 -1
- package/src/console/CommandRunner.ts +0 -82
- package/src/decorators/Lazy.ts +0 -57
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import type { TestResponse } from './TestClient.js';
|
|
2
1
|
/**
|
|
3
|
-
* Fluent HTTP request builder with assertion methods.
|
|
2
|
+
* Fluent HTTP request builder with assertion methods (`@japa/api-client` model).
|
|
4
3
|
*
|
|
5
4
|
* await client
|
|
6
|
-
* .
|
|
5
|
+
* .get('/api/users/42')
|
|
7
6
|
* .withAuth(user)
|
|
8
|
-
* .
|
|
9
|
-
* .
|
|
7
|
+
* .assertOk()
|
|
8
|
+
* .assertBody({ id: 42 })
|
|
10
9
|
*
|
|
11
|
-
* The builder chains: setters
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* The builder chains SYNCHRONOUSLY: setters and assertion methods both return
|
|
11
|
+
* `this`. Assertions are LAZY — each registers a check; the request is sent once
|
|
12
|
+
* and every check runs, in order, when the builder is awaited (it is thenable,
|
|
13
|
+
* so `await builder` resolves to the {@link ApiResponse}). A plain
|
|
14
|
+
* `await client.get('/x')` (no assertion) just sends and returns the response.
|
|
14
15
|
*/
|
|
16
|
+
import type { Readable } from 'node:stream';
|
|
17
|
+
import { ApiResponse, type StatusAssertions, type TestResponse } from './ApiResponse.js';
|
|
18
|
+
export { ApiResponse, deepEqual, partialMatch, type ResponseCookie, type ResponseError, type ResponseFile, type TestResponse, } from './ApiResponse.js';
|
|
15
19
|
export interface AuthSubject {
|
|
16
20
|
/** String or numeric user id — used by `withAuth` / `asUser` to sign the session. */
|
|
17
21
|
id: string | number;
|
|
@@ -24,7 +28,20 @@ export interface AuthStrategy {
|
|
|
24
28
|
/** Compute cookies for session-based strategies. */
|
|
25
29
|
cookiesFor?(subject: AuthSubject): Record<string, string> | Promise<Record<string, string>>;
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
/**
|
|
32
|
+
* HTTP methods. The common verbs are named; `request(url, method)` also accepts
|
|
33
|
+
* any other method (e.g. `TRACE`, `CONNECT`) — Japa parity — via the wider
|
|
34
|
+
* string fallback.
|
|
35
|
+
*/
|
|
36
|
+
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'TRACE' | 'CONNECT' | (string & {});
|
|
37
|
+
/** Primitive accepted as a query-string value (mirrors `.qs()` in japa/api-client). */
|
|
38
|
+
type QueryValue = string | number | boolean;
|
|
39
|
+
/** Query-string map — a value or an array of values (repeated key). */
|
|
40
|
+
export type QueryParams = Record<string, QueryValue | ReadonlyArray<QueryValue>>;
|
|
41
|
+
/** A scalar accepted by `form()`/`fields()` — Japa parity (arrays repeat the key). */
|
|
42
|
+
export type FieldValue = string | number | boolean | Buffer;
|
|
43
|
+
/** A value accepted by a multipart `field()`/`file()` — Japa parity (incl. streams/blobs). */
|
|
44
|
+
export type MultipartValue = string | number | boolean | Buffer | Blob | Readable;
|
|
28
45
|
/**
|
|
29
46
|
* Internal low-level sender — matches what the TestClient exposes.
|
|
30
47
|
* Accepting it as an injected callable keeps RequestBuilder framework-agnostic.
|
|
@@ -32,10 +49,12 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
|
32
49
|
export type HttpSender = (method: HttpMethod, path: string, init: {
|
|
33
50
|
headers: Record<string, string>;
|
|
34
51
|
body: Buffer;
|
|
52
|
+
/** Per-request socket timeout (ms) — Japa `.timeout()`. Sender may honour it. */
|
|
53
|
+
timeoutMs?: number;
|
|
35
54
|
}) => Promise<TestResponse>;
|
|
36
55
|
/** Options for a multipart file part — mirrors Adonis/japa's `.file()` options. */
|
|
37
56
|
export interface FilePart {
|
|
38
|
-
/** Filename advertised in the part's `Content-Disposition`. Defaults to the field name. */
|
|
57
|
+
/** Filename advertised in the part's `Content-Disposition`. Defaults to the field name / basename. */
|
|
39
58
|
filename?: string;
|
|
40
59
|
/** MIME type of the part. Defaults to `application/octet-stream`. */
|
|
41
60
|
contentType?: string;
|
|
@@ -44,45 +63,146 @@ export declare class RequestBuilder {
|
|
|
44
63
|
#private;
|
|
45
64
|
constructor(sender: HttpSender, method: HttpMethod, path: string, authStrategy?: AuthStrategy | null);
|
|
46
65
|
headers(map: Record<string, string>): this;
|
|
47
|
-
header(name: string, value: string): this;
|
|
66
|
+
header(name: string, value: string | string[]): this;
|
|
48
67
|
json(data: unknown): this;
|
|
68
|
+
/** Japa `.unsafeJson()` — set a JSON body without any transform (alias of {@link json}). */
|
|
69
|
+
unsafeJson(data: unknown): this;
|
|
49
70
|
body(data: Buffer | string, contentType?: string): this;
|
|
50
|
-
form(data: Record<string,
|
|
71
|
+
form(data: Record<string, FieldValue | FieldValue[]>): this;
|
|
72
|
+
/** Japa `.unsafeForm()` — set a urlencoded body without transform (alias of {@link form}). */
|
|
73
|
+
unsafeForm(data: Record<string, FieldValue | FieldValue[]>): this;
|
|
51
74
|
/**
|
|
52
|
-
* Add a `multipart/form-data`
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* `Content-Type` header are produced at send
|
|
75
|
+
* Add a `multipart/form-data` field — mirrors Adonis/japa's `.field()`. Accepts
|
|
76
|
+
* a string/number/boolean, a Buffer, a Blob, a Readable stream, or an array of
|
|
77
|
+
* these (repeated part). Calling `.field()`/`.fields()`/`.file()` switches the
|
|
78
|
+
* body to multipart; the boundary + `Content-Type` header are produced at send
|
|
79
|
+
* time (streams/blobs are drained to Buffers then).
|
|
56
80
|
*/
|
|
57
|
-
field(name: string, value:
|
|
81
|
+
field(name: string, value: MultipartValue | MultipartValue[]): this;
|
|
82
|
+
/** Add several multipart fields at once — Japa `.fields()`. */
|
|
83
|
+
fields(map: Record<string, MultipartValue | MultipartValue[]>): this;
|
|
58
84
|
/**
|
|
59
85
|
* Attach a file as a `multipart/form-data` part — mirrors Adonis/japa's
|
|
60
|
-
* `.file(field,
|
|
61
|
-
*
|
|
62
|
-
*
|
|
86
|
+
* `.file(field, value, { filename, contentType })`. `value` is a Buffer, a
|
|
87
|
+
* Blob, a Readable stream, OR a string absolute PATH to a file on disk (read at
|
|
88
|
+
* call time, Japa parity). The filename defaults to the path basename / field
|
|
89
|
+
* name; streams/blobs are drained to Buffers at send time.
|
|
63
90
|
*/
|
|
64
|
-
file(field: string,
|
|
91
|
+
file(field: string, value: Buffer | string | Blob | Readable, options?: FilePart): this;
|
|
65
92
|
cookies(map: Record<string, string>): this;
|
|
66
93
|
cookie(name: string, value: string): this;
|
|
94
|
+
/**
|
|
95
|
+
* Append query-string params — mirrors japa/api-client's `.qs()`. Values are
|
|
96
|
+
* URL-encoded; arrays repeat the key (`?tag=a&tag=b`). Merges with any query
|
|
97
|
+
* string already on the path and with earlier `.qs()` calls.
|
|
98
|
+
*/
|
|
99
|
+
qs(params: QueryParams): this;
|
|
100
|
+
/**
|
|
101
|
+
* Append query params WITHOUT any validation/normalisation — Japa
|
|
102
|
+
* `.unsafeQs({ … })`. Values are still URL-encoded so the wire stays valid, but
|
|
103
|
+
* (unlike `.qs()`) no key filtering is applied; arrays repeat the key.
|
|
104
|
+
*/
|
|
105
|
+
unsafeQs(params: QueryParams): this;
|
|
106
|
+
/** Pass a bearer token as the `Authorization` header — japa `.bearerToken()`. */
|
|
107
|
+
bearerToken(token: string): this;
|
|
108
|
+
/** Pass HTTP Basic credentials as the `Authorization` header — japa `.basicAuth()`. */
|
|
109
|
+
basicAuth(user: string, password: string): this;
|
|
110
|
+
/**
|
|
111
|
+
* Set the request `Content-Type` from a shorthand (`'json'`, `'form'`, …) or a
|
|
112
|
+
* full MIME type — mirrors japa/api-client's `.type()`.
|
|
113
|
+
*/
|
|
114
|
+
type(mime: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Set the `Accept` header from a shorthand (`'json'`, `'html'`, …) or a full
|
|
117
|
+
* MIME type — mirrors japa/api-client's `.accept()`.
|
|
118
|
+
*/
|
|
119
|
+
accept(mime: string): this;
|
|
120
|
+
/** Per-request timeout in ms — Japa `.timeout()`. Honoured by the sender. */
|
|
121
|
+
timeout(ms: number): this;
|
|
122
|
+
/**
|
|
123
|
+
* Follow up to `count` redirects before resolving — Japa `.redirects()`.
|
|
124
|
+
* Defaults to 5 (Japa default); pass `0` to disable following.
|
|
125
|
+
*/
|
|
126
|
+
redirects(count: number): this;
|
|
127
|
+
/** No-op: the loopback test server has no TLS — Japa `.trustLocalhost()`. */
|
|
128
|
+
trustLocalhost(_trust?: boolean): this;
|
|
129
|
+
/** No-op: no TLS on the loopback test server — Japa `.ca()`. */
|
|
130
|
+
ca(_cert: string): this;
|
|
131
|
+
/** No-op: no TLS on the loopback test server — Japa `.cert()`. */
|
|
132
|
+
cert(_chain: string): this;
|
|
133
|
+
/** No-op: no TLS on the loopback test server — Japa `.privateKey()`. */
|
|
134
|
+
privateKey(_key: string): this;
|
|
135
|
+
/** No-op: no TLS on the loopback test server — Japa `.pfx()`. */
|
|
136
|
+
pfx(_encoded: string | Buffer): this;
|
|
137
|
+
/** No-op: no TLS on the loopback test server — Japa `.disableTLSCerts()`. */
|
|
138
|
+
disableTLSCerts(): this;
|
|
139
|
+
/**
|
|
140
|
+
* Satisfy blackhole's signed double-submit CSRF check: echo the `XSRF-TOKEN`
|
|
141
|
+
* cookie back in the `X-XSRF-TOKEN` header (the pair the server compares).
|
|
142
|
+
*/
|
|
143
|
+
withCsrf(token?: string): this;
|
|
144
|
+
/** japa/api-client's spelling of {@link withCsrf}. */
|
|
145
|
+
withCsrfToken(token?: string): this;
|
|
67
146
|
/**
|
|
68
147
|
* Attach auth for a user. Uses the strategy passed to `client`'s `auth`
|
|
69
|
-
* option
|
|
70
|
-
* shape. Without a strategy, throws at send time.
|
|
148
|
+
* option. Without a strategy, throws at send time.
|
|
71
149
|
*/
|
|
72
150
|
withAuth(subject: AuthSubject): this;
|
|
73
151
|
/** Shortcut for `withAuth({ id: userId })` — user is identified by id only. */
|
|
74
152
|
asUser(userId: string | number): this;
|
|
75
|
-
/** Fire the request (once) and return the
|
|
76
|
-
send(): Promise<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
153
|
+
/** Fire the request (once) and return the rich response. Idempotent. */
|
|
154
|
+
send(): Promise<ApiResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Thenable — `await client.get('/x')` sends the request and resolves to the
|
|
157
|
+
* {@link ApiResponse} (Japa/api-client parity). Assertion methods return `this`;
|
|
158
|
+
* awaiting one resolves via this `then` to the response after running the checks.
|
|
159
|
+
*/
|
|
160
|
+
then<R1 = ApiResponse, R2 = never>(onFulfilled?: ((value: ApiResponse) => R1 | PromiseLike<R1>) | null, onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
|
|
161
|
+
expectStatus(code: number): this;
|
|
162
|
+
expectHeader(name: string, value: string | RegExp): this;
|
|
163
|
+
expectCookie(name: string, value?: string | RegExp): this;
|
|
164
|
+
expectJson(expected: unknown): this;
|
|
165
|
+
assertStatus(code: number): this;
|
|
166
|
+
assertHeader(name: string, value?: string | RegExp): this;
|
|
167
|
+
assertHeaderMissing(name: string): this;
|
|
168
|
+
assertCookie(name: string, value?: string | RegExp): this;
|
|
169
|
+
assertCookieMissing(name: string): this;
|
|
170
|
+
assertBody(expected: unknown): this;
|
|
171
|
+
assertBodyContains(subset: unknown): this;
|
|
172
|
+
assertBodyNotContains(subset: unknown): this;
|
|
173
|
+
assertTextIncludes(substring: string): this;
|
|
174
|
+
assertRedirectsTo(path: string): this;
|
|
175
|
+
/** Print the pending request (method/path/headers/body) — Japa `request.dump()`. */
|
|
176
|
+
dump(): this;
|
|
177
|
+
/** Print only the pending request body — Japa `request.dumpBody()`. */
|
|
178
|
+
dumpBody(): this;
|
|
179
|
+
/** Print only the pending request headers — Japa `request.dumpHeaders()`. */
|
|
180
|
+
dumpHeaders(): this;
|
|
181
|
+
/** Print only the pending request cookies — Japa `request.dumpCookies()`. */
|
|
182
|
+
dumpCookies(): this;
|
|
183
|
+
/**
|
|
184
|
+
* Serialize `data` with a registered serializer and set it as the request body
|
|
185
|
+
* — the send-side twin of {@link ApiResponse.addParser}. Register serializers
|
|
186
|
+
* via {@link RequestBuilder.addSerializer} (Japa `ApiRequest.addSerializer`).
|
|
187
|
+
*/
|
|
188
|
+
serialize(name: string, data: unknown): this;
|
|
189
|
+
/**
|
|
190
|
+
* Register a shared property (Japa `ApiRequest.macro`) or lazy getter
|
|
191
|
+
* (`ApiRequest.getter`). The callback is invoked with `this` bound to the
|
|
192
|
+
* builder AND the builder as its first arg, so both Japa's
|
|
193
|
+
* `function () { return this.header('x') }` and `(req) => …` work.
|
|
194
|
+
*/
|
|
195
|
+
static macro(name: string, value: unknown): void;
|
|
196
|
+
static getter(name: string, fn: (this: RequestBuilder, req: RequestBuilder) => unknown): void;
|
|
197
|
+
/** Register a request body serializer — Japa `ApiRequest.addSerializer`. */
|
|
198
|
+
static addSerializer(name: string, fn: (data: unknown) => {
|
|
199
|
+
body: Buffer;
|
|
200
|
+
contentType: string;
|
|
201
|
+
}): void;
|
|
202
|
+
/** Register a response body parser — Japa `ApiRequest.addParser` (delegates to ApiResponse). */
|
|
203
|
+
static addParser(contentType: string, fn: (body: string, headers: Record<string, string>) => unknown): void;
|
|
204
|
+
}
|
|
205
|
+
/** The status-shortcut assertions (lazy) are typed onto the builder. */
|
|
206
|
+
export interface RequestBuilder extends StatusAssertions<RequestBuilder> {
|
|
81
207
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Partial deep-match. For objects, every key in `expected` must match in
|
|
84
|
-
* `actual`. For arrays, every element in `expected` must match SOMEWHERE in
|
|
85
|
-
* `actual` (order-independent). Primitives compared by strict equality.
|
|
86
|
-
*/
|
|
87
|
-
export declare function partialMatch(actual: unknown, expected: unknown): boolean;
|
|
88
208
|
//# sourceMappingURL=RequestBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestBuilder.d.ts","sourceRoot":"","sources":["../../src/testing/RequestBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RequestBuilder.d.ts","sourceRoot":"","sources":["../../src/testing/RequestBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EACL,WAAW,EAKX,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACL,WAAW,EACX,SAAS,EACT,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,EAAE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